"Chas. Owens" schreef: > eval { > $sql = qq { > INSERT INTO table ( > field1, > field2, > field3, > field4, > field5 > ) > VALUES ( ?, ?, ?, ?, ? ) > }; > > $sth = $mysql->prepare ( $sql ); > $sth->execute ( $value1, $value2, $value3, $value4, $value5 ); > $sth->finish(); > } > if ($@) { > $sql = qq { > UPDATE table > SET field1 = ?, > field2 = ?, > field3 = ? > WHERE field4 = ? > AND field5 = ? > }; > $sth = $mysql->prepare ( $sql ); > $sth->execute ( $value1, $value2, $value3, $value4, $value5 ); > $sth->finish(); > };
1. The "$sth->finish()" is not useful there. 2. With "eval{}" it is more reliable to use this format: eval { ... 1; } or do { $@ ||= "unknown error"; ... }; 3. MySQL has "INSERT ... ON DUPLICATE KEY UPDATE", see http://dev.mysql.com/doc/refman/5.0/en/insert.html -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/