Re: Forms : Transactions

From: Dirk Bellemans <Dirk.Bellemans_at_skynet.belgium>
Date: Sat, 13 Jan 2001 10:25:43 +0100
Message-ID: <93p73d$rd9$2_at_news1.skynet.be>


Ton is right, but only when these two blocks appear in the same form :-) It is possible to code interdependencies between two forms, but I wouldn't advise it because too complicated.

However, you use unnecessary assumptions in your question. It is NOT necessary to have record A inserted into the database in order to use its PK as a foreign key in another table (block). You might as well use technical keys on both tables, fetch the sequence into a local variable and use that value to initialize both the PK of A and the FK of B. In the WHEN-VALIDATE-something (depends on what you want your user interface to be) you check if everything is OK and if not, raise a FORM_TRIGGER_FAILURE, which will invalidate the current action (insert, update, whatever).

HTH,
dirkske.

"Ton Schalke" <tschalke_at_worldonline.nl> wrote in message news:3A560C47.26B96AED_at_worldonline.nl...
> Use a raise form_trigger_failure in your post-insert trigger.
>
> "Jérôme PERRET" wrote:
> >
> > Hi,
> >
> > I want to understand how I can create a transaction for a couple of
 command.
> > My problem is that I got a POST-INSERT trigger on a block (based on
 table A)
> > and this trigger create a record in table B. When my trigger ran into an
> > error, and my record is not created in table B, I want the record not to
 be
> > inserted in table A. I can *NOT* use a PRE-INSERT trigger because table
 B
> > containt a foreign key on table A so A must be inserted before B.
> > Can I told form that my transaction start just before inseting in A and
 end
> > after POST-INSERT trigger ?
> > Must I use an ON-INSERT trigger on table A doing the 2 insertions ?
> > Must I put an EXCEPTION in my POST-INSERT trigger with a rollback ? If
 yes,
> > what about inserting more than one value at the same time : will all
> > insertion be cancelled ?
> > ....
> >
> > Thanks for help
> > Jérôme
Received on Sat Jan 13 2001 - 10:25:43 CET

Original text of this message