Solved

Using INSERT to add data into two tables

Posted on 2007-11-20
2
1,087 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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 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