DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: ANSWER PLEASE

  1. #1
    Join Date
    Feb 2001
    Posts
    35

    Talking

    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,???????)

  2. #2
    Join Date
    Jan 2001
    Posts
    515

    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.

  3. #3
    Join Date
    Jan 2001
    Posts
    515

    Wink It does work

    It does work. I just tried it. Make sure that your subquery is in it's own set of paranthesis.

  4. #4
    Join Date
    Feb 2001
    Posts
    35
    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
  •  


Click Here to Expand Forum to Full Width