Solved

Using INSERT to add data into two tables

Posted on 2007-11-20
2
1,077 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
Comment Utility
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
Comment Utility
That is what I expected... Thanks
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now