cancel
Showing results for 
Search instead for 
Did you mean: 

UPDATE_INSERT Causes Violation of PRIMARY KEY constraint !!

Former Member
0 Kudos

Greeting

I have a very simple file to JDBC scenario and it is working perfectly if I used (Action=INSERT). But this does not fit the requirements because I have to update the existing records and insert as new if the record not found.

The strange thing happens when I set the (Action=UPDATE_INSERT). The update will happen and also the Insert, and sure the insert will fail with "Violation of PRIMARY KEY constraint" error.

Is there any parameters that I can set to make it insert only if the record does not exist?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Yup

I found it, I wasn't passing the primary key under <KEY1> field ,

now that I passed it , it worked like a charm

thank you

Former Member
0 Kudos

Hi Baheej,

Just one thing you need to take care. Make sure the field(s) you mainatained as primary key are all there in the key node of the target data structure.

@ Nithyanandam,

He is using UPDATE_INSERT. This will automatically update the record if the record is already there in the table.

Regards,

Jaishankar

Former Member
0 Kudos

Hi,

This is happening because you are trying to insert the duplicate value for a primary key field. Primary key cannot be a duplicate or a null value.

for eg if Rollno is the primary key for Student table.

you have to give only different roll no for different records.

When ever u insert check whether there is already a record present in the Database with the same id as primary key

If that is a case give a label message or meaningful message that record already exists.

Regards,

Nithiyanandam