Link to home
Start Free TrialLog in
Avatar of tripat
tripat

asked on

Mysql errors

I am using mysql as database with dbi/dbd.

If some error occurs while inserting data in mysql, how to display it or trap it in perl program?
Avatar of thoellri
thoellri

That's totally up to you, but I do have code in place which does something like this:

   $sth=$dbh->prepare("SQL code ...") || errorExit "$DBH::errstr";
   $sth->execute($arg1,$arg2) || errorExit "$DBH::errstr";

where errorExit() is a subroutine that gets the current error message from the failed operation and outputs a line to the error_log identifying the error situation. The user will see a "failed" message and is requested to retry the operation.

Look at the 'perldoc DBI ' pages.

Hope this helps
 Tobias
Avatar of tripat

ASKER

Thanks for your suggestions.

Pl tell me exact location of
'perldoc DBI'.

Also, I am not passing any parameters in execute statement.

Do I need to download any additional library for it or just paste this code in my program.

thanks agian
ASKER CERTIFIED SOLUTION
Avatar of thoellri
thoellri

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial