By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,808 Members | 1,477 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,808 IT Pros & Developers. It's quick & easy.

Update Query "Key Violations" error

P: 10
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
Share this Question
Share on Google+
11 Replies


JConsulting
Expert 100+
P: 603
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

P: 10
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
Expert Mod 10K+
P: 14,534
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
Expert Mod 10K+
P: 14,534
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

P: 10
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
Expert Mod 10K+
P: 14,534
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

P: 10
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
Expert Mod 10K+
P: 14,534
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

P: 10
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
Expert Mod 10K+
P: 14,534
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
Expert Mod 15k+
P: 31,489
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

Post your reply

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