473,545 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

geolemon
39 New Member
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:
ComponentPartNu mber (key)
Quantity

JOB ORDERS TABLE:
AssemblyNumber (key)
BuildQuantity

ASSEMBLY TABLE:
AssemblyNumber (key)
ReferenceID (key)
ComponentPartNu mber

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 4419
geolemon
39 New Member
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 AssemblyPartsCo unts 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,564 Recognized Expert Moderator MVP
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
geolemon
39 New Member
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
geolemon
39 New Member
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,564 Recognized Expert Moderator MVP
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,564 Recognized Expert Moderator MVP
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
geolemon
39 New Member
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,564 Recognized Expert Moderator MVP
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
6379
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 error???? This is the query: strSql = "UPDATE DE_change SET " DE_change.BunName = "'" & Trim(Request.Form("txtBUN")) & "', " & _ DE_change.OwnerName =...
9
9098
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 thing :). I have a table of email addresses of people who want to get invited to parties. Each row contains information like email address, city,...
2
3038
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 terminated. I have 2 databases that I DTS data out of and create a view for each. I'm trying to update from each view, but when I try the first...
4
11320
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 AddressDescription of Entity 456 = AddressDescription of Entity_ID 123 Address1 of Entity 456 = Address1 of Entity_ID 123 City of Entity 456 =...
3
12326
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 ============================= UPDATE dbo_IDX_FRS_account_bal_by_month INNER JOIN ON (dbo_IDX_FRS_account_bal_by_month.account = .account) AND...
7
3520
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" Transactions = name of the table I want to update balance = name of the field i want to update daily balance= name of the query result that I want...
0
1759
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 Executive. The first three reports work fine. However, when I try to change the sorting and grouping to either Account Manger or Account Executive,...
1
1789
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
12192
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 has no value in it. Query: Field: Zipcode Table: tblMemberInfo Update to: Replace(,"""","")
11
12390
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 conversion failure, 24 records due to key violations, 0 records due to lock violations..." The table I'm updating has 4 primary key's, and I'm...
0
7487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7778
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6003
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.