on 04-02-2008 10:59 AM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.