List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:June 15 2001 2:24am
Subject:Re: error checking in MySQL
View as plain text  
At 12:04 PM +1000 6/15/01, M Felipe wrote:
>I need help on testing the database for errors. Basically im writing a perl
>script to operate my database. When i open the database, i need it to return
>an error code if successful. steps such as:

Try running:

	perldoc DBI

and reading the information on checking for errors.  You want to know
about the PrintError and RaiseError attributes.

>
>open database
>check for error (did database open?)
>if error print error message
>else print successful.
>close database
>
>
>use DBI
>$dbh = DBI->connect("DBI:mysql:dbname","user","password");

$dbh will be undef if an error occurred (if RaiseError isn't enabled).

>$sth = $dbh->prepare("SELECT username from MyTable");

$sth will be undef if an error occurred (again, if RaiseError isn't enabled).

>(error checking here)
>
>$sth->execute;
>$dbh->disconnect;
>
>Basically on the error checking part, if successful $errorcode = 0 or if
>there is error $errorCode = 1;
>
>
>
>Thank all,
>Marbeen  Felipe


-- 
Paul DuBois, paul@stripped
Thread
error checking in MySQLM Felipe15 Jun
  • Re: error checking in MySQLPaul DuBois15 Jun