Re: [GENERAL] Trigger function which inserts into table; values from lookup

2007-05-21 Thread novnov
Yes, I think that would work and mabye I'll use that approach. But is there no way to implement as I orginally intended? Also, am I right in thinking that this approach is more efficient than a looping operation? William Leite Araújo wrote: > > Maybe you can use a "LEFT OUTER JOIN" ... >

Re: [GENERAL] Trigger function which inserts into table; values from lookup

2007-05-21 Thread William Leite Araújo
Maybe you can use a "LEFT OUTER JOIN" ... CREATE or REPLACE FUNCTION "public"."tproc_handle_item_active"() RETURNS "pg_catalog"."trigger" AS $BODY$ DECLARE rec_item record; int_org_id integer; BEGIN -- whenever an item is set active; create entries in the following table:

Re: [GENERAL] Trigger function which inserts into table; values from lookup

2007-05-21 Thread novnov
No and update would not be needed; but the capability would be close enough, I'd just skip the update, do nothing for that record. But from the sound of it, the example you're suggesting involves a loop or something of that order. I could have written this using a loop but thought a bulk operatio

Re: [GENERAL] Trigger function which inserts into table; values from lookup

2007-05-21 Thread Raymond O'Donnell
On 21/05/2007 05:26, novnov wrote: OK, but, how do I set this up to do what I need? I want an insert that would create a dupe key to be rolled back, and inserts that would not create dupe keys to be committed. Do you specifically need it in a trigger? I seem to recall an example in the docs

Re: [GENERAL] Trigger function which inserts into table; values from lookup

2007-05-20 Thread novnov
OK, but, how do I set this up to do what I need? I want an insert that would create a dupe key to be rolled back, and inserts that would not create dupe keys to be committed. Tom Lane-2 wrote: > > novnov <[EMAIL PROTECTED]> writes: >> Any clue re my question? > > You've placed the INSERT ins

Re: [GENERAL] Trigger function which inserts into table; values from lookup

2007-05-20 Thread Tom Lane
novnov <[EMAIL PROTECTED]> writes: > Any clue re my question? You've placed the INSERT inside the BEGIN/EXCEPTION block, ergo it's part of the work to be rolled back on exception. regards, tom lane ---(end of broadcast)--- T

Re: [GENERAL] Trigger function which inserts into table; values from lookup

2007-05-20 Thread novnov
It's an after trigger. Any clue re my question? Alvaro Herrera-7 wrote: > > novnov escribió: >> >> Inching closer; the following handles the dupe key error but doesn't >> insert >> the rows it should either. So, the exception is ending the insert, and >> not >> continuing to insert for rows t

Re: [GENERAL] Trigger function which inserts into table; values from lookup

2007-05-20 Thread Alvaro Herrera
novnov escribió: > > Inching closer; the following handles the dupe key error but doesn't insert > the rows it should either. So, the exception is ending the insert, and not > continuing to insert for rows that don't violate the unique key restraint. > Is there a way around this or will I need to

Re: [GENERAL] Trigger function which inserts into table; values from lookup

2007-05-20 Thread novnov
Inching closer; the following handles the dupe key error but doesn't insert the rows it should either. So, the exception is ending the insert, and not continuing to insert for rows that don't violate the unique key restraint. Is there a way around this or will I need to take a different approach?

Re: [GENERAL] Trigger function which inserts into table; values from lookup

2007-05-20 Thread novnov
So, I may have hammered out the basic trigger function. The error trapping part is a complete mystery to me. I'll post the trigger function below in the hopes that someone will at least comment on the error handling part. The error, as expected is 'duplicate key violates unique contraint blah bla