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

Update Query "Key Violations" error

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 trying to update the data in one of them. The data I'm updating shouldn't violate the uniqueness of the multiple primary key's.

How do I get around the "key violations" error so I can update this field?

Thanks.
May 7 '07 #1
11 12370
JConsulting
603 Expert 512MB
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 trying to update the data in one of them. The data I'm updating shouldn't violate the uniqueness of the multiple primary key's.

How do I get around the "key violations" error so I can update this field?

Thanks.
A simple test. Open your linked table directly from the Database window. Enter just your one field (the one you're trying to update with your query) and try to move to the next record. You'll notice that it NEEDS to have data in all fields required by the key. This is the same as if you were to create an index in a native Access table. All fields in the index must be satfied before you are allowed to save the record.
I suggest that if you need to add a record, they "dummy" up the remaining fields in your insert query.
J
May 7 '07 #2
I'm not sure I understand what your saying.

I'm not appending the table (adding records to it), I'm updating the records that are already there, so at no point I'm having null values in the other fields.

btw, when I do try to simply enter the new data in the field I'm trying to update, I get an "odbc call failed" error.
May 7 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
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 trying to update the data in one of them. The data I'm updating shouldn't violate the uniqueness of the multiple primary key's.

How do I get around the "key violations" error so I can update this field?

Thanks.
Post the SQL of your update query. You may inadvertently be adding a null value to some of the records.

Also 4 is a very large composite primary key. Are you sure about the structure of your database.
May 7 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
I'm not sure I understand what your saying.

I'm not appending the table (adding records to it), I'm updating the records that are already there, so at no point I'm having null values in the other fields.

btw, when I do try to simply enter the new data in the field I'm trying to update, I get an "odbc call failed" error.
Sorry I didn't see this before I posted. Are you sure you have update privilages on this table?
May 7 '07 #5
Post the SQL of your update query. You may inadvertently be adding a null value to some of the records.

Also 4 is a very large composite primary key. Are you sure about the structure of your database.
Here's the SQL:

UPDATE HMEPRODUSER_AVG_ET_STATS SET HMEPRODUSER_AVG_ET_STATS.UNIT_CATEGORY = "3A20"
WHERE (((HMEPRODUSER_AVG_ET_STATS.COMMUNITY)="428") AND ((HMEPRODUSER_AVG_ET_STATS.UNIT_CATEGORY)="2A20")) ;

The table has 5 fields, and according to the properties section, 4 of them are primary keys. I do have update priveledges, I was able to update the 5th field which wasn't a primary key.

For the query, I"m updating the category field to "3A20" in all fields where the category field is currently "2A20" and the community field is "428".

Thanks.
May 7 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
The update looks fine. However you will have to check for data validity. Try running the following query ...
Expand|Select|Wrap|Line Numbers
  1. SELECT H1.UNIT_CATEGORY, H2.UNIT_CATEGORY
  2. FROM HMEPRODUSER_AVG_ET_STATS As H1 INNER JOIN
  3. HMEPRODUSER_AVG_ET_STATS As H2
  4. ON H1.FirstPrimaryKey = H2.FirstPrimaryKey
  5. AND  H1.SecondPrimaryKey = H2.SecondPrimaryKey
  6. AND  H1.ThirdPrimaryKey = H2.ThirdPrimaryKey
  7. WHERE H1.COMMUNITY = "428"
  8. AND H1.UNIT_CATEGORY = "2A20"
  9. AND H2.UNIT_CATEGORY = "3A20"
If I've gotten the logic right it should show you if you are trying to duplicate an existing primary key. Replace First, Second and ThirdPrimaryKey with the three other keys besides UNIT_CATEGORY.

Mary
May 7 '07 #7
The query didn't return anything. I know that the information I'm trying to update it to is unique, the only reason the "2A20" is in there in the first place is because of a typo.

The update looks fine. However you will have to check for data validity. Try running the following query ...
Expand|Select|Wrap|Line Numbers
  1. SELECT H1.UNIT_CATEGORY, H2.UNIT_CATEGORY
  2. FROM HMEPRODUSER_AVG_ET_STATS As H1 INNER JOIN
  3. HMEPRODUSER_AVG_ET_STATS As H2
  4. ON H1.FirstPrimaryKey = H2.FirstPrimaryKey
  5. AND  H1.SecondPrimaryKey = H2.SecondPrimaryKey
  6. AND  H1.ThirdPrimaryKey = H2.ThirdPrimaryKey
  7. WHERE H1.COMMUNITY = "428"
  8. AND H1.UNIT_CATEGORY = "2A20"
  9. AND H2.UNIT_CATEGORY = "3A20"
If I've gotten the logic right it should show you if you are trying to duplicate an existing primary key. Replace First, Second and ThirdPrimaryKey with the three other keys besides UNIT_CATEGORY.

Mary
May 7 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
The query didn't return anything. I know that the information I'm trying to update it to is unique, the only reason the "2A20" is in there in the first place is because of a typo.
All I can think of is the problem is in oracle. Why can't you run this update directly in oracle?
May 7 '07 #9
All I can think of is the problem is in oracle. Why can't you run this update directly in oracle?
Well, the most obvious reason is that, aside from setting up odbc linked tables, I don't know oracle. The second reason is that my company has an oracle dba who should be doing this, but never answers his e-mail.

Thanks for your help.
May 7 '07 #10
MMcCarthy
14,534 Expert Mod 8TB
Well, the most obvious reason is that, aside from setting up odbc linked tables, I don't know oracle. The second reason is that my company has an oracle dba who should be doing this, but never answers his e-mail.

Thanks for your help.
Can you set up a Pass thru SQL query?
May 7 '07 #11
NeoPa
32,556 Expert Mod 16PB
Can you set up a Pass thru SQL query?
What do you know about Pass-Thru queries. If you let Mary know what you currently understand about them, she can pitch her answer so that it makes sense to you. You will probably have to set up the connection bit (to Oracle yourself though).
May 11 '07 #12

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

Similar topics

0
by: Koen | last post by:
Hi! What is the best way to check whether a key is pressed without blocking in C++? I know I can use cin.get(c) to get a character from standard input, but this blocks. And I know _kbhit()...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
1
by: shumaker | last post by:
....please. I've found other posts that explain the Cascade options, but the Enforce relationships option still is foggy to me. As to "enforcing relationship for ... UPDATEs"(with cascade NOT...
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" ...
4
by: Mike R | last post by:
Hi, Could someone give me a pointer to do the following: I would like to capture a keystroke from "anywhere" , i.e If the user is in Word, Excel, Myother app, desktop etc... and they press...
5
by: Dave Smithz | last post by:
Hi there, Been working on an evolving DB program for a while now. Suddenly I have come across a situation where I need to update a table based on a group by query. For example, I have a table...
2
by: sbowman | last post by:
I ran the following update query in Sql Server 8.0: update _SMDBA_._CUSTOMER_ set _SMDBA_._CUSTOMER_.client = dbo.results.adid from _SMDBA_._CUSTOMER_, dbo.results where...
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...
10
by: MeeMee | last post by:
Hi I have a problem appending data into an oracle table from access. I imported the new data from an excel sheet into a table in access and useed an append query to add the data into a linked...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.