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!
In reply to Global symbol "$DBI" requires explicit package name by NateTut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |