Subject | Re: [firebird-support] How insert in two tables with FK, on the same transaction ? |
---|---|
Author | Gerson Machado |
Post date | 2007-01-30T12:32:02Z |
Tks Martijn Tonies i did like (above) and workink correct...
Tks again
Gerson
VA_ID_PEDIDO = GEN_ID(TB_PEDIDO_ID_GEN1, 1);
INSERT INTO TB_PEDIDO (ID,
ID_EMPRESA,
DATA_HORA,
SITUACAO,
ID_ENDERECO_FATURA,
ID_ENDERECO_PAP,
ID_ENDERECO_CD,
ID_ENDERECO_COBRANCA)
VALUES
(:VA_ID_PEDIDO,
:VA_ID_EMPRESA,
:VI_DATA_ABRE,
'A',
0,
0,
0,
0);
INSERT INTO TB_PEDIDO_ITENS (ID_PEDIDO,
ID_PRODUTO,
QTDE)
VALUES
(:VA_ID_PEDIDO,
:VI_ID_PRODUTO,
:VI_QTDE);
Martijn Tonies <m.tonies@...> escreveu:
Hi,
Get the PK value for the master table from within the procedure, not
in the trigger.
Then, use this value to create the detail record.
Never EVER use gen_id(..., 0) -> cause it's not multi user safe
at all.
Martijn Tonies
Database Workbench - development tool for Firebird and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/
[Non-text portions of this message have been removed]
Tks again
Gerson
VA_ID_PEDIDO = GEN_ID(TB_PEDIDO_ID_GEN1, 1);
INSERT INTO TB_PEDIDO (ID,
ID_EMPRESA,
DATA_HORA,
SITUACAO,
ID_ENDERECO_FATURA,
ID_ENDERECO_PAP,
ID_ENDERECO_CD,
ID_ENDERECO_COBRANCA)
VALUES
(:VA_ID_PEDIDO,
:VA_ID_EMPRESA,
:VI_DATA_ABRE,
'A',
0,
0,
0,
0);
INSERT INTO TB_PEDIDO_ITENS (ID_PEDIDO,
ID_PRODUTO,
QTDE)
VALUES
(:VA_ID_PEDIDO,
:VI_ID_PRODUTO,
:VI_QTDE);
Martijn Tonies <m.tonies@...> escreveu:
Hi,
Get the PK value for the master table from within the procedure, not
in the trigger.
Then, use this value to create the detail record.
Never EVER use gen_id(..., 0) -> cause it's not multi user safe
at all.
Martijn Tonies
Database Workbench - development tool for Firebird and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/
[Non-text portions of this message have been removed]