Subqueries

From: Bob Pawley <rjpawley(at)shaw(dot)ca>
To: Postgre General <pgsql-general(at)postgresql(dot)org>
Subject: Subqueries
Date: 2005-11-06 21:19:55
Message-ID: 00d501c5e317$d590b270$ac1d4318@OWNER
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rick 2005-11-06 21:33:19 Re: CREATE TEMP TABLE AS ... ON COMMIT DROP fails
Previous Message Andrus Moor 2005-11-06 21:03:43 CREATE TEMP TABLE AS ... ON COMMIT DROP fails