Subject AW: [firebird-support] transaction the hundreth
Author Olaf Kluge
> Table A is the Idoc-Table
> Table B the ORDER and Table C the ORDERPOS.
> One stored procedure do the following
> Insert a record in Table A
> Insert a record in Table B with reference from Table A
> Insert some records in Table C with reference from Table A and Table B
> I have learned, that stored procedures do all in one transaction.
> In Table A there is a trigger After Insert. The problem is, a new record
was
> inserted in Table A, the Trigger runs - but at this time the stored
> procedure has inserted the records in Table B and Table C yet! Why? I
think,
> a stored procedure inserts and commits all data at the same time in one
> transaction?

Not the procedure commits the transaction, but the transaction initiator
(client application) needs to commit/rollback the transaction.

> Currently I have solved the problem with a status-field. On Inserting in
> Table A I set this to 50 (parking) and after Insert in all other tables I
> update the status to 0 - and only at 0 the trigger runs.
> Is there a better solution for this?

Basically, what problem do you have? Do you get an exception somewhere
etc ..., thus you have to build a workaround?
---

Hello Thomas,

No, for this action there is no client application involved at the time.

A Procedure named as PA which creates Test-Data for Table A, B and C started
by IBExpert and commit after calling manually. The procedure do:
insert in Table A,
insert in Table B,
insert in Table C (more records).
I commit the call.

My problem: As soon as a new record were inserted in Table A, a trigger
calls a Stored Procedure to process data (named as PB) (Table A, B, C). I
have test it and at this moment of calling, the records for table B and C
not available yet! In tableA a job is announced but there are no records in
Table B and C yet at this moment of calling this stored procedure PB.



If I set the status from Table A to parking and update this at the end of
inserting Data in Table B and C to a value X, then all data were present. In
this case, the status will be respected by the trigger. (all this with
Procedure PA) The calling (Procedure PB) is done via a trigger, not an
external application.





I think, despite that the stored procedure inserts all data in one
transaction, the trigger runs before the other records were inserted.



Or think I'm wrong?







[Non-text portions of this message have been removed]