Avatar of shaunwingin
shaunwinginFlag for South Africa asked on

MySQL Unique Index & Prevention of Inserting Duplicate Records

HI,

Say, I have a table in MySQL 5.1 with certain indexes that are unique. When I do an insert query, I wish to prevent record duplication & hence the indexes. The stored procedure I have created needs to be run on occasion, more than once in order to fix up any errors.

When an insert query is executed for the second time, I get an error message that the data already exits. This is naturally expected. How can  I suppress this error message from displaying?

TX
Microsoft SQL ServerMySQL ServerSQL

Avatar of undefined
Last Comment
Louis01

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Louis01

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
shaunwingin

Tx, please can you explain what each statement does in above.
Louis01

Refer to the Condition Handling section in the MySql reference documentation for an explanation: http://dev.mysql.com/doc/refman/5.0/en/declare-handler.html
ASKER
shaunwingin

Please xplain the value '23000:
DECLARE CONTINUE HANDLER FOR SQLSTATE '23000
Your help has saved me hundreds of hours of internet surfing.
fblack61
SOLUTION
Louis01

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question