on 01-30-2014 6:16 AM
Dear Experts,
Now i am doing Proxy to JDBC (MYSQL Data Base) scenario. My Requirement is need to send Students list to Hostel Management System, First time i have sent students data to the database and its inserted correctly, Now the data which i have sent earlier has some updates 'say change in phone number, etc ' and additional student lists as well,
when i am trying to send data from ECC its executed successfully, in JDBC receiver channel i am getting following error is given bellow.
JDBC message processing failed; reason Error processing request in sax parser: Error when executing statement for table/stored proc. 'student_sap' (structure 'Statement'): com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Upholding foreign key constraints for table 'student_sap', entry '10001265', key 1 would lead to a duplicate entry.
MP: exception caught with cause com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'student_sap' (structure 'Statement'): com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Upholding foreign key constraints for table 'student_sap', entry '10001265', key 1 would lead to a duplicate entry.
Here '10001265' is student roll number and its primary Key.. i am using UPDATE_INSERT sql statement.
Kindly suggest the way forward.
Thanks in advance..
Regards,
Senthil kumar .j
Hi Senthil,
This is a known issue explained the solution in the question 19 in this note 831162 - FAQ: XI 3.0 / PI 7.0 / PI 7.1 / PI 7.3 JDBC Adapter
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Senthil,
Please check the below content of s note: 831162 as mentioned by Inaki
19. Using UPDATE_INSERT with MS SQL Server:java.sql.SQLException Cannot insert duplicate key
Q: When I construct payload using UPDATE_INSERT, I get Cannot insert duplicate key in object XXX. How do I resolve this?
A: You need to create UNIQUE INDEX for the table with 'IGNORE_DUP_KEY' option.
For instance, if the table name is TEST and its primary key is id, then following statement may be executed using Query analyzer tool.CREATE UNIQUE INDEX TEST_INDEX ON TEST(id) WITH IGNORE_DUP_KEY After executing the above command, please re-run the scenario.
Regards
Raj
Dear Raj,
Thanks for the suggestion, in my case the table name is student_sap and primary key is roll.
CREATE UNIQUE INDEX TEST_INDEX ON student_sap(roll) WITH IGNORE_DUP_KEY
i am trying to execute the above query in mysql server it throwing an error..
sql error (1064) : you have an error in yours sql syntax;
check the manual that corresponds to yours MYSQL server version for the right syntax to use near 'IGNORE_DUP_KEY' at line 1
Kindly suggest me.
Regards,
Senthil.
Hi Senthil,
I think in your version you must put: CREATE UNIQUE INDEX TEST_INDEX ON student_sap(roll) WITH IGNORE_DUP_KEY = ON
Check the sintaxis here: http://technet.microsoft.com/es-es/library/ms186869.aspx
Regards.
Hi Senthil - That is already defined as primary key so i dont think you can add unique index to it.
Possible options i see here -
1)
Chage your receiver structure to type 6 as explained in the below document so that you can execute the your own DML statements directly on the database.
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
and this way now you have two options to handle your primary key i.e. INSERT IGNORE or REPLACE
INSERT IGNORE and REPLACE should be chosen according to the duplicate-handling behavior you want to effect.
INSERT IGNORE keeps the first of a set of duplicated records and discards the rest. REPLACE keeps the last of a set of duplicates and erase out any earlier ones.
----------------------------------
2) Add a UNIQUE index rather than a PRIMARY KEY to a table that means you have to drop the primary key and add unique key.
Please refer to the below document to understand the behaviour os mySQL in handling the duplicates.
http://www.tutorialspoint.com/mysql/mysql-handling-duplicates.htm
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.