Use an automatic generated ID
Hi all:
I'm trying to register an invoice that has:
a) a Header (table A - autogenerated ID)
b) a Body (table B - Foreign Key from Table A)
The point is that I'm trying to encapsulate that in a TRANSACTION with the following statements:
start transaction;
insert into A (ID) values (0); (ID=Integer autoincremental PK)
select @IDCAB=LAST_INSERT_ID();
insert into B (ID,FKCAB) values (0,@IDCAB); (ID=Integer autoincremental PK)
commit;
Assuming that the value of ID in A was 34, when I see the B's new register, the field FKCAB is NULL instead of 34.
Could you help me please?
Subject
Views
Written By
Posted
Use an automatic generated ID
9570
December 23, 2008 08:31AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.