Subject | Re: [ib-support] Re: Changing Insert to Update. |
---|---|
Author | Claudio Valderrama C. |
Post date | 2002-02-11T06:54:50Z |
""John Peterson"" <jcp@...> wrote in message
news:01dd01c1b2ae$da26e400$326410ac@gw5300...
Create a view.
Make sure the view is non-updatable (see Langref)
Create a before insert trigger for the view. Triggers on view can change the
semantics. Triggers on tables can't change the semantics of the original
operation.
The trigger tries to insert into the base table. Failing that (use WHEN),
the trigger tries to update a record. Do not trap a possible update error in
the trigger as it's possible that your update causes conflict with another
user and the non-trapped error goes back to the client; otherwise you don't
notice the failure.
C.
--
Claudio Valderrama C. - http://www.cvalde.com - http://www.firebirdSql.org
Independent developer
Owner of the Interbase® WebRing
news:01dd01c1b2ae$da26e400$326410ac@gw5300...
> Thanks Helen,That
> Your response answers my question (which I didn't actually ask :(( ).
> being....Will the Insert error occur in the Before Insert Trigger? YourI don't think the tale is so simple.
> solution would indicate that it does.
Create a view.
Make sure the view is non-updatable (see Langref)
Create a before insert trigger for the view. Triggers on view can change the
semantics. Triggers on tables can't change the semantics of the original
operation.
The trigger tries to insert into the base table. Failing that (use WHEN),
the trigger tries to update a record. Do not trap a possible update error in
the trigger as it's possible that your update causes conflict with another
user and the non-trapped error goes back to the client; otherwise you don't
notice the failure.
C.
--
Claudio Valderrama C. - http://www.cvalde.com - http://www.firebirdSql.org
Independent developer
Owner of the Interbase® WebRing