Subqueries - Mailing list pgsql-general

From Bob Pawley
Subject Subqueries
Date
Msg-id 00d501c5e317$d590b270$ac1d4318@OWNER
Whole thread Raw
Responses Re: Subqueries
List pgsql-general

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

pgsql-general by date:

Previous
From: ellis@spinics.net (Rick)
Date:
Subject: Re: CREATE TEMP TABLE AS ... ON COMMIT DROP fails
Next
From: Tom Lane
Date:
Subject: Re: CREATE TEMP TABLE AS ... ON COMMIT DROP fails