Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Perl: Dealing with Database Errors

Perl: Dealing with Database Errors
{filelink=14653}

#!/usr/bin/perl
use DBI;
$dbh = DBI->connect('dbi:mysql:database', 'username', 'password',
                    { RaiseError => 1 , AutoCommit => 1});
eval {
  $dbh->do("$SQL");
<span id="more-78"></span>  $sth = $dbh->prepare("select * from table");
  $sth->execute( );
  while (@row = $sth->fetchrow_array)
   {
    print $row;
  }
};
if ($@)
{
  # Exception
  print "Exception $_!";
}

No comments yet.

Leave a Comment