RE: Perl Issues

  • From: "Jeremiah Wilton" <jeremiah@xxxxxxxxxxx>
  • To: <JApplewhite@xxxxxxxxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Thu, 21 Feb 2008 14:39:12 -0800

JApplewhite@xxxxxxxxxxxxx wrote:

> 1.  Can Exception Handling be easily done in Perl?  If so, any good
examples I can point them to? 

Yes.

use DBI;
my $dbh = DBI->connect(
                        'dbi:Oracle:','', '',
                        { ora_session_mode => 2, # / as sysdba
                          PrintError => 0  #Suppresses the automatic error
reporting to STDERR
                        }
) or die "Cannot connect: $DBI::errstr\n";

my $sth = $dbh->prepare(
                        "select foo from bar"
                        ) or print "Caught an exception preparing the
cursor: $DBI::errstr\n";
print "Duh, I'm still alive!  Now I can do something since I know I caught
an error\n";

$dbh->disconnect;

Regards,

Jeremiah Wilton
ORA-600 Consulting
http://www.ora-600.net

--
//www.freelists.org/webpage/oracle-l


Other related posts: