In article <[EMAIL PROTECTED]>, Adaikalavan Ramasamy <[EMAIL PROTECTED]> writes:
> This seems more like the solution I want. I am using perl-DBI and when > there is an error (i.e. duplicate insert), the rest of the scrip it not > executed. But this is gives me the following error. What am I doing > wrong ? mysql> desc tb; > +-----------+-------------+------+-----+---------+----------------+ > | Field | Type | Null | Key | Default | Extra | > +-----------+-------------+------+-----+---------+----------------+ > | myID | int(11) | | PRI | NULL | auto_increment | > | firstname | varchar(10) | YES | MUL | NULL | | > | lastname | varchar(10) | YES | | NULL | | > +-----------+-------------+------+-----+---------+----------------+ > 3 rows in set (0.00 sec) mysql> INSERT INTO tb (firstname, lastname) VALUES ('Jack', 'Doe') ON > DUPLICATE KEY UPDATE lastname = lastname; > ERROR 1064: You have an error in your SQL syntax near 'ON DUPLICATE KEY > UPDATE lastname = lastname' at line 1 The "ON DUPLICATE KEY..." clause is new in MySQL 4.1.0. > Alternatively, I am looking for 'try' equivalent in perl, so that if the > insert is duplicate, the rest of the script is still run. Thank you. Most people use DBI and DBD::mysql to access a MySQL server from Perl. Then you don't need something like "try". Just disable $dbh->{RaiseError}, execute the INSERT, and then check $dbh->err. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]