P
priyom
Hi,
Say I have the following table:
CREATE TABLE TEST (
COL1 BIGINT PRIMARY KEY,
COL2 VARCHAR(50),
COL3 VARCHAR(50,
COL4 INT,
CONSTRAINT uniq_2_3 UNIQUE KEY(COL2, COL3)
);
I want to data to this table through JDBC. Is there any way to check if
the data I'm tryin to insert violates the unique constraint?
On a more generic note, during insertion, is there any way to check if
the data I'm trying to insert to a table, violates any particular
(unique or not) constraints on it?
Of course, if I try to insert a row with duplicate data, it would cause
an SQL exception but is there any way to programmatically retrieve the
cause?
I do not want to execute a select query before insertion.
Note: I am using MySql.
Thanks in advance,
Priyom
Say I have the following table:
CREATE TABLE TEST (
COL1 BIGINT PRIMARY KEY,
COL2 VARCHAR(50),
COL3 VARCHAR(50,
COL4 INT,
CONSTRAINT uniq_2_3 UNIQUE KEY(COL2, COL3)
);
I want to data to this table through JDBC. Is there any way to check if
the data I'm tryin to insert violates the unique constraint?
On a more generic note, during insertion, is there any way to check if
the data I'm trying to insert to a table, violates any particular
(unique or not) constraints on it?
Of course, if I try to insert a row with duplicate data, it would cause
an SQL exception but is there any way to programmatically retrieve the
cause?
I do not want to execute a select query before insertion.
Note: I am using MySql.
Thanks in advance,
Priyom