Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see if MYSQL truncated a field during an Update usint 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 updated with the truncated value.

Can anyone tell me how to show this error?

like image 283
Jeremey Avatar asked Jan 21 '23 22:01

Jeremey


1 Answers

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).

like image 70
Eugene Yarmash Avatar answered Jan 23 '23 11:01

Eugene Yarmash