J
jrefactors
how to avoid inserting duplicate key to the table?
For example, the EMPLOYEE TABLE has field EMPID (primary key) and NAME
In the Java program, if the following sql statement one by one, it will
throw SQLException.
INSERT INTO EMPLOYEE (EMPID, NAME) VALUES ('1001','Joe');
INSERT INTO EMPLOYEE (EMPID, NAME) VALUES ('1001','Sue');
In my case, should I check if the key value already exists in the
table, then update the record instead of inserting the record?
please advise. thanks!!
For example, the EMPLOYEE TABLE has field EMPID (primary key) and NAME
In the Java program, if the following sql statement one by one, it will
throw SQLException.
INSERT INTO EMPLOYEE (EMPID, NAME) VALUES ('1001','Joe');
INSERT INTO EMPLOYEE (EMPID, NAME) VALUES ('1001','Sue');
In my case, should I check if the key value already exists in the
table, then update the record instead of inserting the record?
please advise. thanks!!