in reply to Mysql smallint out of range. How to fetch warning?

IMHO it might be even better to forbid mysql to do that insert at all. if you turn to strict mode, the insert will fail and output a warning. with the "RaiseError" option on, it will die:
my $dbh = DBI->connect(..., { RaiseError => 1 }); $dbh->do(q{SET sql_mode="STRICT_TRANS_TABLES,STRICT_ALL_TABLES"}); # insert
Then you can be sure to not get wrong data inserted, but you have to put an eval block around it to catch the error.

Replies are listed 'Best First'.
Re^2: Mysql smallint out of range. How to fetch warning?
by bannaN (Acolyte) on Oct 17, 2010 at 18:44 UTC
    Thanks, this sorted out the problem. Wasnt aware of the strict options