Search Postgresql Archives

Subqueries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Last week I received help form the list in inserting a serial row of one table (process) into a row in a table called specification.

 

I was able to expand that to include inserting the same information into a table called pipe.

-------------------

create or replace function base() returns trigger as $$

            begin

            insert into specification (fluid_id) values (new.fluid_id);

            insert into pipe (fluid_id) values (new.fluid_id);

            return null;

            end;

            $$ language plpgsql;

 

            create trigger trig1 after insert on process

            for each row execute procedure base();

----------------

This works well.

 

Now I want to modify the program so that only those rows from process that have ip in the column ip_op_reactor are inserted into pipe.

 

Following is my best result after studying every piece of documentation available to me.

 

------------------

            create or replace function base() returns trigger as $$

            begin

            insert into specification (fluid_id) values (new.fluid_id);

 

            select fluid_id as fi from process pr;

            select ip_op_reactor as iop from pr ;

            select fluid_id as fi from pipe pi

            (select fi

            from pr where iop = 'ip',

                         

            insert into pi (fi) values (new.fi));

           

            return null;

            end;

            $$ language plpgsql;

 

            create trigger trig1 after insert on process

            for each row execute procedure base();

-----------------

This is the error I get.

------------------

ERROR:  SELECT query has no destination for result data

HINT:  If you want to discard the results, use PERFORM instead.

CONTEXT:  PL/pgSQL function "base" line 4 at SQL statement

----------------

I would very much appreciate any help as to where I am going wrong.

 

Thanks

 

Bob Pawley

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux