I'm trying to perform an update, and I can't avoid this error - I've tried this query what must be 5 different very fundamentally different ways now.
Arg.
I used to be a DBA in large DB2 and SQL Server environments, but I'm a little rusty, plus I'm very new to Access.
I am trying to perform a calculation based on information in a few tables, and use the result to update another.
Should be simple, here's what counts from the tables that matter:
INVENTORY TABLE:
ComponentPartNumber (key)
Quantity
JOB ORDERS TABLE:
AssemblyNumber (key)
BuildQuantity
ASSEMBLY TABLE:
AssemblyNumber (key)
ReferenceID (key)
ComponentPartNumber
The JOB ORDERS table contains information on how many assemblies we are contracted to build.
The ASSEMBLY table contains reference ID's for each location in an electronic assembly, and the part number of the component that is placed at each location. One component might be used in several places in an assembly.
The INVENTORY table contains information on how many component parts we have in inventory.
Basically, I'm looking to sum up how many of each component is used in a particular assembly, and multiply that by how many assemblies we built. I want to take that number (by component, of course) and update my inventory by subtracting it from the existing Qty.
No matter what I do, I get the error "Operation must use an updatable query".
I've tried using a stored query to join ASSEMBLY to JOB ORDERS and precalculate a NewQty so I could do a straightforward "set Qty=NewQty", I've tried doing it all in one query - but I can't get around doing a count(*) at some level - and since I can't do that IN my update statement (since I can't do a "group by"), I have to do it in a stored query. But - I'm not updating that query - so I'm nothing if not puzzled by this error! All joins at all times are simple inner joins.
Where am I going wrong here?
8 4409
I'm not sure if it'll help since this is just ONE way I've tried it.
Actual table names used here - not hard to figure out: - UPDATE Inventory
-
INNER JOIN (Parts INNER JOIN ((AssemblyParts INNER JOIN JobOrders ON (AssemblyParts.AssyPN = JobOrders.AssyPN) AND (AssemblyParts.Rev = JobOrders.Rev)) INNER JOIN AssemblyPartsCounts ON (AssemblyParts.AssyPN = AssemblyPartsCounts.AssyPN) AND (AssemblyParts.Rev = AssemblyPartsCounts.Rev) AND (AssemblyParts.BOMPN = AssemblyPartsCounts.MfgPN)) ON Parts.MfgPN = AssemblyParts.UsedPN) ON Parts.MfgPN = Inventory.MfgPN
-
SET Inventory.Qty = Inventory.Qty-(JobOrders.POQty*AssemblyPartsCounts.Used)
-
WHERE AssemblyParts.AssyPN="SCMA-7";
The stored query AssemblyPartsCounts code is as follows: - SELECT Assemblies.AssyPN, Assemblies.Rev, Assemblies.MfgPN, Count(*) AS Used
-
FROM Assemblies
-
GROUP BY Assemblies.AssyPN, Assemblies.Rev Assemblies.MfgPN;
NeoPa 32,556
Expert Mod 16PB
Any query that links, in any way, to a non-updatable query, is by necessity, non-updatable itself.
Consider updating the data multiple times (A = A + 1) rather than in one go (A = Count()).
Any query that links, in any way, to a non-updatable query, is by necessity, non-updatable itself.
Consider updating the data multiple times (A = A + 1) rather than in one go (A = Count()).
Not "by necessity"...
I can do this using views in other DBMS's ;-)
I didn't think I created a non-updatable query, as I'm not updating the query - I"m updating the table directly, and attempting to join the query with the group-by merely adjacently, to pull my new value from - as I'd do outside the world of Access.
I was more suspicious of a syntax error, as I've been fighting with this "query builder", finally resorting to molesting an innocent Select query for the right join syntax - which is why I was suspicious of it.
What is the correct work-around? This obviously isn't an uncommon scenario, needing to sum and count to update data, right? ;-)
Consider updating the data multiple times (A = A + 1) rather than in one go (A = Count()).
Do you mean by simply joining and letting the duplication do the work?
I suppose I can test that easily enough using a Select query to ensure that I'm not inadvertantly causing multiplication or other cartesian-product-like ill effects.
I definitely am a fan of the explicit rather than the implicit by rule... but everyone has to step out of their comfort zone sometime, right?
NeoPa 32,556
Expert Mod 16PB
Not "by necessity"...
I can do this using views in other DBMS's ;-)
Oh absolutely. I did intend to explain that this is a specifically MS Access situation.
I didn't think I created a non-updatable query, as I'm not updating the query - I"m updating the table directly, and attempting to join the query with the group-by merely adjacently, to pull my new value from - as I'd do outside the world of Access.
However, as that is now included into the query, the whole query that it is a part of is now non-updatable. Sorry. That's Access-World for you. It does have limitations when compared to grown-up RDBMSs.
I was more suspicious of a syntax error, as I've been fighting with this "query builder", finally resorting to molesting an innocent Select query for the right join syntax - which is why I was suspicious of it.
I never use RIGHT JOINs myself. Only INNER, LEFT & RIGHT supported in Jet though.
What is the correct work-around? This obviously isn't an uncommon scenario, needing to sum and count to update data, right? ;-)
The method I proposed it what I usually use.
Otherwise, I think most people simply use an intermediate (scratch) table to get around the limitations.
NeoPa 32,556
Expert Mod 16PB
Do you mean by simply joining and letting the duplication do the work?
I suppose I can test that easily enough using a Select query to ensure that I'm not inadvertantly causing multiplication or other cartesian-product-like ill effects.
If I understand you correctly then, Yes - and it's wise to check for cartesian product side-effects.
I definitely am a fan of the explicit rather than the implicit by rule... but everyone has to step out of their comfort zone sometime, right?
Me too. I would recommend using the explicit even when venturing beyond comfort zones ;)
It can help minimise the damage when you do get lost.
I never use RIGHT JOINs myself. Only INNER, LEFT & RIGHT supported in Jet though.
Oh, sorry -
by "right", I meant "correct"...
I was struggling with the corrrect join syntax, because I'm used to simply doing something like this: - SELECT *
-
FROM TABLE1
-
inner join TABLE2 on KEY1=KEY2
-
inner join TABLE3 on KEY1=KEY3
-
inner join TABLE4 on KEY3=KEY4
I'm amazed that Access apparently wants some sort of "join order" rather than letting the database query engine do that analysis - at least I imagine that's the function of the absolutely-impossible-to-read groupings of parenthesis that it wraps around everything (reference my code above - that was Access generated!). Yike!
NeoPa 32,556
Expert Mod 16PB
I'd argue with you, but I don't like to be on the wrong side ;D
You're absolutely right of course, and I sympathise. Access can provide a decent and easy to get into front-end though. It does have quite a few benefits. Jet SQL isn't really up to grown-up RDBMS standards though.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Lisa |
last post by:
can someone tell me what is wrong with this query? I've tried every
combo that I can think of - adding &,"", "'", ) everywhere I can think
of and I keep getting an 'Expected end of statement...
|
by: David Berman |
last post by:
I'm having a problem with an update operation in a stored procedure. It
runs so slowly that it is unusable, unless I comment a part out in which
case it is very fast. However, I need the whole...
|
by: Steve Bishop |
last post by:
I'm having problems using an update query. I get the error: Server: Msg
8152, Level 16, State 9, Procedure SP_MemberUpdate, Line 3
String or binary data would be truncated.
The statement has been...
|
by: deko |
last post by:
I'm trying to update the address record of an existing record in my mdb with
values from another existing record in the same table. In pseudo code it
might look like this:
UPDATE tblAddress SET...
|
by: jallegue |
last post by:
I am working with MS-Access 2002. The two tables that I am working with
are:
dbo_IDX_FRS_account_bal_by_month ==> this is a linked table to SQL
== local table
The query that is executed is...
|
by: Mark Carlyle via AccessMonster.com |
last post by:
I have this update query that I am trying to run. I know the syntax is
messed up but do not know how to correct it.
Select 'UPDATE', Transactions,'Set = where =
' From "Get Daily Balances"
...
|
by: colt |
last post by:
I have a query that is pretty straightforward and I am trying to
generate 5 reports from that query. The reports produce totals by
Project Manager, Category, Client, Account Manager and Account...
|
by: vssp |
last post by:
Hi friends
Thanks for your repaly for all my question..
I need one update query. I have selected the datas are insert with coma ",".
Query
SELECT city
FROM `locations`
WHERE city REGEXP ','
|
by: Reedsp |
last post by:
OS: MS XP
Access version: 2003 SP2
I am trying to use an update query to replace quote marks with nothing. In essence, I'm removing quote marks. I get a error message when a field is empty or...
|
by: gnortenjones |
last post by:
I have a linked table (to an oracle db), and I am trying to run a simple update query against it to change some data, but I am getting the following error:
"...didn't update 0 fields due to a type...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
|
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...
| |