Re: Inserting Data - Mailing list pgsql-general

From Bob Pawley
Subject Re: Inserting Data
Date
Msg-id 009101c6c706$b9d62c30$8e904618@owner
Whole thread Raw
In response to Inserting Data  (Bob Pawley <rjpawley@shaw.ca>)
Responses Re: Inserting Data
List pgsql-general
Thanks Tom

But my problem with this solution comes whan I try to qualify with  a
'where' clause.
For instance -
 ----
 create or replace function loop_association() returns trigger as $$
 begin

 insert into p_id.loops (monitor) values (new.devices_id)
 where new.device_number = library.devices.device_number
 and library.devices.type_ = 'mon' ;

 return null ;
 end ;
 $$ language plpgsql ;

 create trigger loop after insert on p_id.devices
 for each row execute procedure loop_association();
----
Gives me an error.

What am I doing wrong?

Bob
----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Bob Pawley" <rjpawley@shaw.ca>
Cc: "Michael Fuhr" <mike@fuhr.org>; "Postgresql"
<pgsql-general@postgresql.org>
Sent: Wednesday, August 23, 2006 3:31 PM
Subject: Re: [GENERAL] Inserting Data


> Bob Pawley <rjpawley@shaw.ca> writes:
>> I thought the NEW qualified the select.
>
> Not at all; that would rather cripple the ability to write interesting
> triggers.  I think what you are really wanting to do here is just
>
> insert into p_id.loops (monitor) values (new.devices_id);
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: invalid byte sequence ?
Next
From: Tom Lane
Date:
Subject: Re: CASCADING could not open relation with OID