# if using perl and DBI pseudo code

die $ERROR if ($dbh->errstr() && $dbh->errstr() !~ /Duplicate Error/);

If $dbh->errstr() =~ /Duplicate Error/
  do your specified logic
Else 
  Return inserted id



- Dathan Vance Pattishall
  - Sr. Programmer and mySQL DBA for FriendFinder Inc.
  - http://friendfinder.com/go/p40688


-->-----Original Message-----
-->From: dan orlic [mailto:[EMAIL PROTECTED]
-->Sent: Monday, October 13, 2003 11:45 AM
-->To: [EMAIL PROTECTED]
-->Subject: insert failure, move on question
-->
-->How, in a sql script, do I gracefully fail an insert?  For example, I
-->insert a record that has an primary key of 1, and it already exists.
I
-->want my script to
-->Move down to the next record, not fail out.  Thanks!
-->
-->dan



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to