Hello Zarquav,
Welcome to the Monastery. As fellow Monk Corion connect to your DB like this (pseudo code):
DBI->connect_cached( $dsn, $username, $auth, { PrintError => 1, RaiseError => 1, AutoInactiveDestroy => 1})or die "Could not connect to: " $DBI::er +rstr ."\n";
You can read in the documentation about those errors DBI/AutoInactiveDestroy. After setting the errors and connecting to your DB prepare you select statement like this (pseudo code):
my $checkExist = $dbh->prepare("INSERT IGNORE INTO your statement here +"); if (!$checkExist->execute()) { die "Error: ". $checkExist->errstr ."\n"; }
Or you can do it as recommended from the documentation DBI/RaiseError:
use Try::Tiny; try { ... $sth->execute(); ... } catch { # $sth->err and $DBI::err will be true if error was from DBI warn $_; # print the error (which Try::Tiny puts into $_) ... # do whatever you need to deal with the error };
Hope this helps. Let us know if it resolved your problem or guided you to your solution, BR.
In reply to Re: DBI Problem
by thanos1983
in thread SOLVED: DBI Problem
by Zarquav
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |