-
I insert one record in master table.
After that i must insert record in detail table,
but in insert statement i must know what is the value of PK
of master record.
All id's in master and detail tables are make with sequences
ex:
master table: 111.aaa(PK),222.aaa,333.aaa
detail table: 111.bbb(PK),222.bbb(FK<---111.aaa)
1) insert into aaa values (222.aaa,333.aaa)
2) insert into bbb values (111.bbb,???????)
-
Try a subquery
insert into aaa values (222.aaa,333.aaa)
2) insert into bbb values (111.bbb,???????)
INSERT INTO BBB VALUES(111.bbb,select ... from aaa;)
I'm not sure if this will work but give it a try.
-
It does work
It does work. I just tried it. Make sure that your subquery is in it's own set of paranthesis.
-
But what must i use in those select statement instead of ...?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|