我开始使用perl和sybase。我正在尝试执行一个存储过程
use strict;
use warnings FATAL => 'all';
use DBI qw(:sql_types);
use DBD::Sybase;
use Data::Dumper;
my $dbh = DBI->connect($connect,$usr,$pwd)or die "Couldn't connect!n" . DBI->errstr;
my $sth = $dbh->prepare("exec progress_web @id=?, @as_select=?");
$sth->bind_param(1,5374,SQL_INTERGER);
$sth->bind_param(2,1,SQL_INTERGER);
$sth->execute;
while(my $row = $sth->fetch) {
print Dumper($row);
}
$sth->finish;
$dbh->disconnect;
连接正常,但当我尝试执行存储过程时,我会得到
Bareword "SQL_INTERGER" not allowed while "strict subs" in use at ./sybase_test.pl line 15.
Bareword "SQL_INTERGER" not allowed while "strict subs" in use at ./sybase_test.pl line 16.
Execution of ./sybase_test.pl aborted due to compilation errors.
删除使用严格和警告我得到。
DBI::st=HASH(0x55ad3d830630)->bind_param(...): attribute parameter 'SQL_INTERGER' is not a hash ref at ./sybase_test.pl line 16.
它不是SQL_INTERGER,而是SQL_INTEGER。如文件中所列。
您应该知道,删除use strict
并不能解决问题,它会隐藏问题。这可能让人感到安慰,但无济于事。
您可以使用:
$sth->bind_param(1,5374,4);
$sth->bind_param(2,1,4);
$sth->execute;