Solved

Using INSERT to add data into two tables

Posted on 2007-11-20
2
1,102 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
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…
Suggested Courses

627 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