Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using INSERT to add data into two tables

Posted on 2007-11-20
2
Medium Priority
?
1,110 Views
Last Modified: 2013-12-25
I have 2 tables. One table 'POHEADER' contains the address, vendor, and PO number. The second table 'PODETAILS' contains the product, quantity, pricing, etc..

I am trying to write a sequel that creates a PO automatically.

I am unsure on how to link up the POHEADER and PODETAILS so the PODETAILS writes data to the correct POHEADER. The primary key is 'POID' (assigned by the informix database) between the two tables.


0
Comment
Question by:RETEZE
2 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 2000 total points
ID: 20336333
This can only be done with two separate SQL Statements, inserting into POHEADER first, then into PODETAILS (assuming that you have Referential integrity active, so that a Detail record requires a corresponding header record to exist, before the detail can be inserted).


Insert into PoHeader Values (....)

execute that statement, then

Insert into PODetails values(...) with the POID from the inserted POHeader record.

AW
0
 

Author Closing Comment

by:RETEZE
ID: 31410274
That is what I expected... Thanks
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question