in reply to Error messages from DBI

Look closer at the example in the DBI documentation. Your connect() would probably work this way:

my $dbh = DBI->connect($dsn,$user,$password, { RaiseError => 1, AutoCommit => 0 }) || die "Database connection failed: $DBI::errstr";

The last argument is a hash reference. If you're not familiar with references, have a look at perlreftut and perlref. After that, maybe References quick reference.

Update: Also, since you're using RaiseError, you don't need to die explicitly. DBI will do that for you if there's a problem.

Replies are listed 'Best First'.
Re^2: Error messages from DBI (\%attr)
by nbierman (Novice) on Jun 12, 2008 at 17:00 UTC
    I changed the connect() to this: my $dbh = DBI->connect($dsn,$user,$password) or die $DBI::errstr; That gets me past the syntax warning and the HASH error. Now Perl can't find DBD/Oracle.pm, but that's a different issue. Thanks for your help.

      You do realize that you've not turned on the RaiseError and not turned of AutoCommit, right? Read the parent again, you'll want to use his syntax -- all you were missing was a pair of braces.

      <radiant.matrix>
      Ramblings and references
      “A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort.” — Herm Albright
      I haven't found a problem yet that can't be solved by a well-placed trebuchet