Triggers after insert

Started by Fran Fabrizioover 24 years ago3 messagesgeneral
Jump to latest
#1Fran Fabrizio
ffabrizio@mmrd.com

I seem to be observing that on a trigger I've created to fire
AFTER INSERT, if I intentionally introduce some sort of syntax error to
the trigger for example, and insert a row, the row does not appear in
the table, even though I've declared it to fire after insert. Shouldn't
that row be there regardless of whether the trigger does or does not
fire successfully? Or is this currently not how it works? The docs
seemed to indicate that it would work that way.

The end result is that I need to make sure the insert happens whether or
not the trigger is successful.

Thanks,
Fran

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Fran Fabrizio (#1)
Re: Triggers after insert

Fran Fabrizio <ffabrizio@mmrd.com> writes:

I seem to be observing that on a trigger I've created to fire
AFTER INSERT, if I intentionally introduce some sort of syntax error to
the trigger for example, and insert a row, the row does not appear in
the table, even though I've declared it to fire after insert. Shouldn't
that row be there regardless of whether the trigger does or does not
fire successfully?

No. Failure of an AFTER trigger will still abort the transaction.

regards, tom lane

#3Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Fran Fabrizio (#1)
Re: Triggers after insert

On Thu, 25 Oct 2001, Fran Fabrizio wrote:

I seem to be observing that on a trigger I've created to fire
AFTER INSERT, if I intentionally introduce some sort of syntax error to
the trigger for example, and insert a row, the row does not appear in
the table, even though I've declared it to fire after insert. Shouldn't
that row be there regardless of whether the trigger does or does not
fire successfully? Or is this currently not how it works? The docs
seemed to indicate that it would work that way.

I think the syntax error is an error condition which will cause a
rollback. Technically, that would mean your row was inserted and then
rolled back.

The end result is that I need to make sure the insert happens whether or
not the trigger is successful.

I don't think you can get this right now using triggers.