trigger AFTER INSERT
--0016367b6c30caea42048da19a18
Content-Type: text/plain; charset=ISO-8859-1
Hi,
I think that I have a conceptual problem and I hope anyone could help me.
If I write a trigger AFTER INSERT and I have one error in this trigger, the
record (that I think was already inserted) is not inserted.
Example:
INSERT INTO tableX <record1>
trigger sumRecords AFTER INSERT under tableX to accumulate the records
inserted by hour
if there is an error in the commands executed for this record, <record1> is
not in the tableX
If this occurs in a trigger BEFORE INSERT, I can understand, but, if it is
AFTER INSERT, I believe that the record is already inserted.
What is wrong on it?
Thanks in advance
Josi Perez
--0016367b6c30caea42048da19a18
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,<br><br>I think that I have a conceptual problem and I hope anyone could=
help me.<br><br>If I write a trigger AFTER INSERT and I have one error in =
this trigger, the record (that I think was already inserted) is not inserte=
d.<br>
Example:<br><br>INSERT INTO tableX <record1><br>trigger sumRecords AF=
TER INSERT under tableX to accumulate the records inserted by hour<br>if th=
ere is an error in the commands executed for this record, <record1> i=
s not in the tableX<br>
<br>If this occurs in a trigger BEFORE INSERT, I can understand, but, if it=
is AFTER INSERT, I believe that the record is already inserted.<br>What is=
wrong on it?<br><br>Thanks in advance<br>Josi Perez<br><div style=3D"visib=
ility: hidden; display: inline;" id=3D"avg_ls_inline_popup">
</div><style type=3D"text/css">#avg_ls_inline_popup { position:absolute; =
z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0px; widt=
h: 240px; overflow: hidden; word-wrap: break-word; color: black; font-s=
ize: 10px; text-align: left; line-height: 13px;}</style>
--0016367b6c30caea42048da19a18--
Re: trigger AFTER INSERT
"Josi Perez (3T Systems)" <josiperez3t [at] gmail.com> writes:
> If I write a trigger AFTER INSERT and I have one error in this trigger, the
> record (that I think was already inserted) is not inserted.
Sure, because the whole transaction is rolled back on error.
regards, tom lane
--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Re: trigger AFTER INSERT
--0022152d7c5bed2add048df30333
Content-Type: text/plain; charset=ISO-8859-1
Thank you for your answer.
Without considering the errors, the transaction should not start after the
AFTER INSERT?
Josi Perez
2010/8/12 Tom Lane <tgl [at] sss.pgh.pa.us>
> "Josi Perez (3T Systems)" <josiperez3t [at] gmail.com> writes:
> > If I write a trigger AFTER INSERT and I have one error in this trigger,
> the
> > record (that I think was already inserted) is not inserted.
>
> Sure, because the whole transaction is rolled back on error.
>
> regards, tom lane
>
--0022152d7c5bed2add048df30333
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Thank you for your answer.<br><span id=3D"result_box" class=3D"short_text">=
<span style=3D"" title=3D"">Without considering the errors, the transaction=
should not start after</span></span> the AFTER INSERT?<br>Josi Perez<br><b=
r><br>
<div class=3D"gmail_quote">2010/8/12 Tom Lane <span dir=3D"ltr"><<a href=
=3D"mailto:tgl [at] sss.pgh.pa.us">tgl [at] sss.pgh.pa.us</a>></span><br><blockquo=
te class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; border-left: 1=
px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class=3D"im">"Josi Perez (3T Systems)" <<a href=3D"mailto=
:josiperez3t [at] gmail.com">josiperez3t [at] gmail.com</a>> writes:<br>
> If I write a trigger AFTER INSERT and I have one error in this trigger=
, the<br>
> record (that I think was already inserted) is not inserted.<br>
<br>
</div>Sure, because the whole transaction is rolled back on error.<br>
<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0regards, tom lane<br>
</blockquote></div><br><div style=3D"visibility: hidden; display: inline;" =
id=3D"avg_ls_inline_popup"></div><style type=3D"text/css">#avg_ls_inline_po=
pup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0=
px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-w=
ord; color: black; font-size: 10px; text-align: left; line-height: 13px=
;}</style>
--0022152d7c5bed2add048df30333--
Re: trigger AFTER INSERT
"Josi Perez (3T Systems)" <josiperez3t [at] gmail.com> wrote:
> Without considering the errors, the transaction should not start
> after the AFTER INSERT?
Anything happening in a trigger is always part of the same database
transaction as the database action which fired the trigger.
-Kevin
--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin