NateTut has asked for the wisdom of the Perl Monks concerning the following question:
Why am I getting this error? This code has worked for me many times in the past. This is on ActiveState 5.10, but I tried it on 5.12 and got the same error.
use strict; use warnings; use Data::Dumper; use DBI; use DBD::ODBC; $|++; my $DSN = $ARGV[0]; my $UserName = $ARGV[1]; my $PassWord = $ARGV[2]; my $dbh = DBI->connect("dbi:ODBC:$DSN", $UserName, $PassWord, { R +aiseError => 1, AutoCommit => 1 }) or die "Couldn't connect to:\[$DSN +\] as \[$UserName\]: $DBI->errstr"; my @SELRow; my $SQL_Statement = " Select * From DBC.DBCInfo ; "; my $SELh = $dbh->prepare($SQL_Statement); $SELh->execute; while(@SELRow = $SELh->fetchrow_array) { print("$SELRow[0]:$SELRow[1]\n"); } $SELh->finish(); $dbh->disconnect(); print(Dumper(\@SELRow));
Solved!
changed: $DBI->errstr to $DBI::errstr Thanks AnonyMonk!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Global symbol "$DBI" requires explicit package name
by Anonymous Monk on Dec 07, 2010 at 18:26 UTC | |
by NateTut (Deacon) on Dec 07, 2010 at 18:58 UTC | |
by ikegami (Patriarch) on Dec 07, 2010 at 22:23 UTC | |
by Anonymous Monk on Dec 07, 2010 at 23:22 UTC | |
by ikegami (Patriarch) on Dec 08, 2010 at 00:27 UTC |
Back to
Seekers of Perl Wisdom