posted 23 years ago
Hi,
I'm going desperate now and need HELP!
Im trying to do a batchUpdate with a prepared statement:
"INSERT INTO WEB_CLOSET "
+ "(ITEM_CD, MAT_CD, COLOR_CD, SIZE_CD, LOCATION_CD, CUST_ID, LAST_UPDT_DATE) "
+ "(SELECT ?, ?, ?, ?, ?, ?, SYSDATE "
+ "FROM DUAL "
+ "WHERE NOT EXISTS "
+ "(SELECT * FROM WEB_CLOSET W2 "
+ "WHERE W2.ITEM_CD = ? ))"
and:
prepStatement.setString(1, "A");
prepStatement.setString(2, "A");
prepStatement.setString(3, "A");
prepStatement.setString(4, "A");
prepStatement.setString(5, "001" );
prepStatement.setLong(6, 1);
prepStatement.setString(7, "A");
prepStatement.addBatch();
but i can't get parameter 7 to work. This insert should happen if the data is not already there, but not if the data is already in teh database. But i get a
ORA-00001: unique constraint violated
the second time I run it (when the data is already in there)
If i convert parameter 7 and use 1 instead of "A" it works...
Has anyone got any ideas on how to solve this?
// tina