How can I find out if MYSQL field was truncated during usint Perl DBI update

When I run this Update SQL in DBVis, I get an error (Data truncation: Data is too long for the Description column in row 1).

However, in Perl (DBI), this does not give me an error, I suppose, because the record was actually updated with a truncated value.

Can someone tell me how to show this error?

+4
source share
3 answers

As data is deleted, you can use SHOW WARNINGS to see it. And you can propagate warnings to fatal errors by setting the SQL Mode server to one that prohibits truncation (for example, TRADITIONAL ).

+6
source

When you say "it does not give me an error", how do you check it? You can usually check the status of a DBI operation by checking the value of $DBI::err or $dbh->errstr . In addition, you can cause errors to be visible as exceptions if you configure your connection with the RaiseError => 1 option.

See the documentation and find "err" for a detailed discussion of all the options available to you.

+2
source

interpreted as warnings instead of errors,

So,

 show warnings; 

more details: http://dev.mysql.com/doc/refman/5.0/en/faqs-cjk.html#qandaitem-B-11-1-9

+1
source

All Articles