473,395 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

SQL UPDATE statement question

Good morning,

This is a tough one for me to explain, so if I make no sense, just let
me know :).

I have created a purchase order entry system where there are four
tables that hold all neccessary details of the parts ordered on the
purchase order:

1) tblPurchaseOrder: holds POnumber (primary key), date, closed? etc.
2) tblPurchaseOrderDetails: holds DetailID (primary key), POnumber from
tblPurchaseOrder, PartNumber ordered, delivery date etc.
3) tblPurchaseOrderReceipt: holds ReceiptID (prim. key), DetailID from
tblPurchaseOrderDetails, quantity received, date received etc.

I have created a way to revise a purchase order when neccessary. A new
record is created in tblPurchaseOrder, and the original record is
updated to not current through its field tblPurchaseOrder.fldCurrent.
At this point, the new PO holds no records in tblPurchaseOrderDetails.

A temp table is created and holds all the records from
tblPurchaseOrderDetails corresponding to the original
tblPurchaseOrder.POnumber. The temp table also has a field named
OldDetailID which holds the DetailID from the original
tblPurchaseOrderDetails records.

The user now modifies the temp table and adds or deletes records as
neccessary. Added records obviously have no value in OldDetailID.

Once the user has made all neccessary modifications, then the Update PO
button is clicked and the temp table data is appended to
tblPurchaseOrderDetails. The old records are not deleted or changed,
since it's correspnding POnumber has been made "not current".

Finally, any record in tblPurchaseOrderReceipt that had the original
DetailID must be updated to hold the new DetailID. This is where I am
stuck. Is it possible to create an UPDATE query that can change all
tblPurchaseOrderReciept records with DetailID equalling the old
DetailIDs in tblPurchaseOrderDetails to the new DetailID values in
tblPurchaseOrderDetails.

Thanks in advance

Tim

Sep 19 '06 #1
2 1701
Rephrasing and condensing the original question to see if I understand
you correctly.

You have a table with IDs in use, and a (temporary) table with pairs of
IDs; you want all IDs in the first table that occur in the second table
to be 'translated', changed, updated.

I haven't been succesful in creating an Update query that does this; it
must have to do with including the right fields from the various primary
keys.

tr*****@gmail.com schreef:
>
Finally, any record in tblPurchaseOrderReceipt that had the original
DetailID must be updated to hold the new DetailID. This is where I am
stuck. Is it possible to create an UPDATE query that can change all
tblPurchaseOrderReciept records with DetailID equalling the old
DetailIDs in tblPurchaseOrderDetails to the new DetailID values in
tblPurchaseOrderDetails.

Thanks in advance

Tim
--
Bas Cost Budde
Holland
Sep 19 '06 #2
LOL. That is exactly what i want to do. I think I might have to use DAO
and recordsets to accomplish this (Which is not the end of the world,
but annoying since I think there should be some SQL way to do this).

Tim

Bas Cost Budde wrote:
Rephrasing and condensing the original question to see if I understand
you correctly.

You have a table with IDs in use, and a (temporary) table with pairs of
IDs; you want all IDs in the first table that occur in the second table
to be 'translated', changed, updated.

I haven't been succesful in creating an Update query that does this; it
must have to do with including the right fields from the various primary
keys.

tr*****@gmail.com schreef:

Finally, any record in tblPurchaseOrderReceipt that had the original
DetailID must be updated to hold the new DetailID. This is where I am
stuck. Is it possible to create an UPDATE query that can change all
tblPurchaseOrderReciept records with DetailID equalling the old
DetailIDs in tblPurchaseOrderDetails to the new DetailID values in
tblPurchaseOrderDetails.

Thanks in advance

Tim

--
Bas Cost Budde
Holland
Sep 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: jayson_13 | last post by:
Hi, I need to implement a counter and i face problem of locking so hope that u guys can help me. I try to do test like this : 1st connection SELECT * FROM nextkey WHERE tblname = 'PLCN'...
1
by: shottarum | last post by:
I currently have 2 tables as follows: CREATE TABLE . ( mhan8 int, mhac02 varchar(5), mhmot varchar(5), mhupmj int )
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
5
by: Klemens | last post by:
I get SQL30090 reason 18 by trying to do an insert in a federated table and an update in a local table in one transaction Do I have to change some settings to get done or ist this not possible by...
15
by: graham | last post by:
Hi all, <bitching and moaning section> I am asking for any help I can get here... I am at the end of my tether... I don;t consider myself a genius in any way whatsoever, but I do believe I have...
1
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
1
by: cindy | last post by:
this is the call private void Page_Load(object sender, System.EventArgs e) { OdbcConnection connection = new OdbcConnection ("DSN=PFW52"); CreateDataAdapter(connection); } this is the code,...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.