Triggers after insert
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
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
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.