Thread: Trigger - will not perform INSERT
ex: CREATE TRIGGER mytrig AFTER INSERT OR UPDATE ON foo1 FOR EACH ROW EXECUTE PROCEDURE updatefoo1('datarow'); The command itself is able to be executed without error. However, what then happens, is that whenever the application attempts to insert a record into foo1, it simply doesn't insert. Once I take the trigger off, it beings inserting again. I have checked permissions but INSERT only FAILS while trigger is enabled.. Thanks...Michelle -- View this message in context: http://www.nabble.com/Trigger---will-not-perform-INSERT-tp14282848p14282848.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On Dec 11, 2007 3:35 PM, smiley2211 <smiley2211@yahoo.com> wrote: > Thanks...Michelle Please post DDL plus sample code/data to increase the odds of having someone help you.
On Dec 11, 2007, at 21:35, smiley2211 wrote: > > ex: > > CREATE TRIGGER mytrig AFTER INSERT OR UPDATE ON foo1 FOR EACH ROW > EXECUTE > PROCEDURE updatefoo1('datarow'); > > The command itself is able to be executed without error. However, > what then > happens, is that whenever the application attempts to insert a > record into > foo1, it simply doesn't insert. Once I take the trigger off, it beings > inserting again. > > I have checked permissions but INSERT only FAILS while trigger is > enabled.. > > Thanks...Michelle This would be expected behaviour if the trigger were a BEFORE INSERT one (instead of AFTER) and the procedure returned NULL. You might want to check that is really not the case. AFTER INSERT triggers don't fire until the row is actually inserted into the table, so the only possibility I can see for the behaviour you describe is that the stored procedure removes the record that was just inserted. Maybe there are statements in that procedure that attempt to remove possible duplicates that also happen to match on the new record? Regards, -- Alban Hertroys "If you throw your hands up in the air, how're you gonna catch them?" !DSPAM:737,475fc5969651302216542!
Ok, thanks...I will do some more testing and see what I get... -- View this message in context: http://www.nabble.com/Trigger---will-not-perform-INSERT-tp14282848p14296002.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
Thanks all...ended up being a missing field in my table definition...sorry to bother you all ... :wistle: -- View this message in context: http://www.nabble.com/Trigger---will-not-perform-INSERT-tp14282848p14297220.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.