Welcome Guest, Not a member yet? Register   Sign In
duplicate entry error. How to catch?

(This post was last modified: 07-06-2021, 10:53 AM by richb201.)

I have a table where I am inserting rows. I have created the table with this:
$sql = "CREATE TABLE BC_PR_list_temp(
          taxyear  VARCHAR(10),
          employee_email VARCHAR(80),
          employee  VARCHAR(80),       
          qualified_dollars int NOT NULL,
          title varchar(80),
          role varchar(80),
          num_BC int NOT NULL,
          num_PR int NOT NULL,
          type varchar(4),
          item varchar(80),
          dollarsPerBC int NOT NULL,
          dollarsPerPR int NOT NULL,
          business_component_string varchar(120),
          project_string varchar(120),
          CONSTRAINT OnlyOne UNIQUE (employee_email, item, qualified_dollars)
At some later time I am inserting rows but sometimes insert the same row twice. That is why I put in the Constraint. Now when I try to put in the same row twice, I get this error:
Error Number: 1062
Duplicate entry '[email protected]' for key 'BC_PR_list_temp.OnlyOne' 
That is a correct call to constraint but I want to catch that error and just continue. How do I just ignore that error. Right now the entire program stops!
proof that an old dog can learn new tricks

Messages In This Thread
duplicate entry error. How to catch? - by richb201 - 07-06-2021, 10:52 AM

Theme © iAndrew 2016 - Forum software by © MyBB