Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert into multiple tables

Status
Not open for further replies.

TGJ

Programmer
Jan 31, 2005
64
CA
Hi, I have a situation where I need to insert into 2 tables that are related through ID and V3DETAILKEY.

The tables are:
V3DETAILSERVICE (ID VARCHAR(9), V3DETAILKEY VARCHAR(20), SERVICE NUMBER(7,4))

V3DETAILSALARY (ID VARCHAR(9), V3DETAILKEY VARCHAR(20), SALARY NUMBER(9,2))

So, the ID is 000001, SERVICE is 12.00, SALARY is 2200.00, V3DETAILKEY is automatically generated. Now if I was just going to insert into each table separately this is how I would do it:

INSERT INTO V3DETAILSERVICE
VALUES ('000001', V3DETAILKEY_SEQ.NEXTVAL, 12.00)

INSERT INTO V3DETAILSALARY
VALUES ('000001', V3DETAILKEY_SEQ.NEXTVAL, 2200.00)

However I need to update both tables with the same V3DETAILKEY and I am not sure how to do this.

Can anyone help me? Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top