0
  1. I have three tables, DISTRIBUTION_LIST, USERS, and ADDRESSES.
  2. Single object 'distribution_list' has multiple users and addresses.
  3. I want to create transaction which will write to those three table together and FOREIGN_KEY in tables USERS and ADDRESSES is PRIMARY_KEY from DISTRIBUTION_LIST which is AUTO INCREMENT.

Actually I have described my problem already, how to know PRIMARY_KEY from DISTRIBUTION_LIST when I create statement to insert data into USERS and ADDRESSES? One solution to calculate PRIMARY_KEY manually, but possible there's more elegant solution for this task? enter image description here

Anatoly
  • 5,056
  • 9
  • 62
  • 136
  • 1
    I don't know if it works the same way (same commands) in other DBs but in PostgreSQL it possible to generate id from sequence `nextVal('seqName')` and get current id with `currVal('seqName')` – Iwo Kucharski Feb 18 '14 at 16:06
  • Thank you! After an investigation I'm going to use same solution for DB2. Generating sequence and than use value from it. – Anatoly Feb 18 '14 at 17:49

0 Answers0