开发者

How can I see if MySQL truncated a field during an Update using Perl DBI

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

However, in Perl (DBI), this is not giving me an error I am guessing because the record actually was upda开发者_高级运维ted with the truncated value.

Can anyone tell me how to show this error?


As data truncations produce warnings you can use SHOW WARNINGS to see them. And you can promote warnings to fatal errors by setting server's SQL Mode to one that forbids truncations (e.g. TRADITIONAL).


When you say "this is not giving me an error", how are you checking for it? Usually, you can check the status of a DBI operation by checking the value of $DBI::err or $dbh->errstr. Also, you can force errors to be visible as exceptions if you set up your connection with the option RaiseError => 1.

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


Is interpreted as warnings instead of errors,

So,

show warnings;

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜