[EMAIL PROTECTED] wrote:

Please also note hat UPDATE returns the number of records updated. If your UPDATE returns 0, you know that the record does not exist, and you might want to INSERT instead.



There is one situation where the number of records updated will return
0, yet the row exists. If you update the record with the exact same
information, mySQL will return a count of 0 rows updated. Yet the row
exists.


Hi, how can I find out the return value from update if I execute update in perl dbi?
Here is my sample code:
$sql ="update transaction set salesvolume=$salesvol, netsales=$netsales,
transtype=\"$transtype\", returnreason=\"$returnreason\"
where prodcode=\"$prodcode\" and custcode=\"$custcode\" and date=$transdate";
$udpate_sql = qq {$sql;};
$sth = $dbh->prepare($update_sql) || die "prepare: $update_sql: $DBI::errstr";
$sth->execute || die "Unable to execute query: $dbh->errstr\n";
$sth->finish;
print $sql;


Currently I found somethingn strange with mysql(perhaps with perl dbi as well), after setup 1 or 2 test data, I tried to make a change to one of the fiield in a table, but after update is completed, I don't see the corresponding field in a record is updated by the new value.

If I copy the update statement exactly from the output of the print statement ( print $sql), and paste it to the mysql login prompt to execute it, the update statement update the record instantly. I don't know what is happening here, why perl dbi does not do what the update statement supposed to do? Have I missed a commit statement? but I don't have idea how to place a commit statement to perl dbi.

Thanks
Sam

             Brad Eacker ([EMAIL PROTECTED])







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



Reply via email to