473,406 Members | 2,698 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,406 software developers and data experts.

Update query: "Operation must use an updatable query" error

geolemon
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?
Sep 16 '08 #1
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:
Expand|Select|Wrap|Line Numbers
  1. UPDATE  Inventory 
  2. 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
  3. SET Inventory.Qty = Inventory.Qty-(JobOrders.POQty*AssemblyPartsCounts.Used)
  4. WHERE AssemblyParts.AssyPN="SCMA-7";
The stored query AssemblyPartsCounts code is as follows:
Expand|Select|Wrap|Line Numbers
  1. SELECT Assemblies.AssyPN, Assemblies.Rev, Assemblies.MfgPN, Count(*) AS Used
  2. FROM Assemblies
  3. GROUP BY Assemblies.AssyPN, Assemblies.Rev Assemblies.MfgPN;
Sep 16 '08 #2
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()).
Sep 16 '08 #3
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? ;-)
Sep 16 '08 #4
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?
Sep 16 '08 #5
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.
Sep 16 '08 #6
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.
Sep 16 '08 #7
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:
Expand|Select|Wrap|Line Numbers
  1. SELECT * 
  2. FROM TABLE1 
  3. inner join TABLE2 on KEY1=KEY2
  4. inner join TABLE3 on KEY1=KEY3
  5. 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!
Sep 16 '08 #8
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.
Sep 16 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
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...
9
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...
2
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...
4
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...
3
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...
7
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" ...
0
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...
1
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 ','
2
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...
11
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
Oralloy
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,...
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...

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.