I am getting the error:
" Violation of PRIMARY KEY constraint 'PK_tblCustomsT ariffTreeMap'. Cannot insert duplicate key in object 'dbo.tblCustoms TariffCodeTreeM ap'."
However, the record I am inserting does not represent a duplicate on the primary key.
To ensure this I ran the following and still got the error: - update tblCustomsTariffCodeTreeMap
-
set TariffCodeID = (SELECT max(tariffcodeid)+1 from tblCustomsTariffCodeTreeMap)
-
where TreeNodeID = 955
If I'm explicitly inserting a value which is 1 greater than the max value, I'm puzzled as to how it can be a duplicate...?
The primary key is defined as follows: - index_name : PK_tblCustomsTa riffTreeMap
index_descripti on : clustered, unique, primary key located on PRIMARY
index_keys : TariffCodeID, TreeNodeID
Any suggestions?
2 12145 ck9663 2,878
Recognized Expert Specialist
I am getting the error:
"Violation of PRIMARY KEY constraint 'PK_tblCustomsT ariffTreeMap'. Cannot insert duplicate key in object 'dbo.tblCustoms TariffCodeTreeM ap'."
However, the record I am inserting does not represent a duplicate on the primary key.
To ensure this I ran the following and still got the error: - update tblCustomsTariffCodeTreeMap
-
set TariffCodeID = (SELECT max(tariffcodeid)+1 from tblCustomsTariffCodeTreeMap)
-
where TreeNodeID = 955
If I'm explicitly inserting a value which is 1 greater than the max value, I'm puzzled as to how it can be a duplicate...?
The primary key is defined as follows:- index_name : PK_tblCustomsTa riffTreeMap
index_descripti on : clustered, unique, primary key located on PRIMARY
index_keys : TariffCodeID, TreeNodeID
Any suggestions?
first the why...your query is an update and a select....your select will run first..so if the max+1, let's say is = 16...it's the same as doing: - update tblCustomsTariffCodeTreeMap
-
set TariffCodeID = 16
-
where TreeNodeID = 955
so if you have two or more records with TreeNodeID = 955, you'll experience this problem with PK violation....wh at are you trying to do on your table?
first the why...your query is an update and a select....your select will run first..so if the max+1, let's say is = 16...it's the same as doing: - update tblCustomsTariffCodeTreeMap
-
set TariffCodeID = 16
-
where TreeNodeID = 955
so if you have two or more records with TreeNodeID = 955, you'll experience this problem with PK violation....wh at are you trying to do on your table?
Thank you ck9663. This is a sure sign that I've been staring at the screen too long! I was originally dealing with an INSERT which I changed to an UPDATE but did not modify the criteria properly. Then when I got the error I didn't see the obvious problem (a classic case of seeing what you expect to see!). thanks again - I'm back from lala land now.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: ATS |
last post by:
ERR - WebClient.DownloadData returns "protocol violation"
Please help,
I'm getting a "protocol violation" from a site that is working perfectly
fine when I issue WebClient.DownloadData as such:
WebClient WebClient_Temp = new WebClient();
byte zbyteTemp = WebClient_Temp.DownloadData
(
|
by: Mike Hunter |
last post by:
(Please CC me on any replies as I'm not on the list)
Hi,
After a recent power failure, a program that uses a pgsql backend
(netdisco) started to send me nastygrams. I tried the author's suggestion
of running a VACUUM FULL ANALYZE VERBOSE;, but it still sends me the
messages. The data in the database isn't too important, i.e. I'm willing
to blow away data to try to fix the problem. Any suggestions?
|
by: borajetta |
last post by:
ERROR: duplicate key violates unique constraint "pg_class_oid_index"
I found a post earlier but wanted to post up my info as the other persons did not look like the same type of error:
I tried to cluster the isbn_table
cluster isbn_index_code on isbn_table;
ERROR: duplicate key violates unique constraint "pg_class_oid_index"
The table looks like this
|
by: Toufik |
last post by:
Hi,
I've the folowing error "Concurency violation, The update command affected 0
records", when I execute the save command "DA.Update(DS, "tblName")"
DA is a dataadapter linked to a commandBuilder.
How can I debug the error, know what is the error... what is the exact
update command
|
by: Scott McDermott |
last post by:
I have an application that is making an HTTP request with
HttpWebRequest.GetRequest. Unless I set 'httpWebRequest
useUnsafeHeaderParsing="true"' in the web.config, I get a
'The server committed a protocol violation. Section=ResponseStatusLine' error.
Here is an example of the session that generates the error:
--- snip ---
GET <someURLHTTP/1.0
| |
by: Curten |
last post by:
Hi,
I want to read data from a txt-file that looks like this:
aaa 4 12.45
bbb 3 7.34
ccc 12 3.45
and store the data in an array of structures. The struct and array are defined like this
|
by: Morgan Cheng |
last post by:
I have a crawler in C#. The main functionality relies on HttpWebRequest
and HttpWebResponse. It shows that some webpages are not downloaded
successfully. A WebException is thrown with info "exception happens:
The server committed a protocol violation. Section=ResponseHeader
Detail=CR must be followed by LF".
I know that HTTP requires headers seperated by CRLF, but it also
recommend UserAgent implementation to tolerate CR-only and LF-only...
|
by: weird0 |
last post by:
I have two tables accounts and ATM and i am trying to insert a tuple
in ATM with accountId as foreign key. But even this simple work,I
encounter the following error:
The INSERT statement conflicted with the FOREIGN KEY constraint
"FK_ATM_Accounts". The conflict occurred in database "G:\DOCUMENTS AND
SETTINGS\ADMINISTRATOR\DESKTOP\VERSION2\APP_DATA\BANKINGDB.MDF", table
"dbo.Accounts", column 'acc_Id'.
please sugggest how can i fix...
|
by: hadad.yaniv |
last post by:
Hello,
i am new to c++,
i hav a vector of typed object:
vector<Man*People;
When i do a second pushback, even for the same object the program
crash say:
"An Access Violation (Segmentation fault) raised in your program"
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |