Home > Back-end >  Perl fails to execute sybase stored procedure
Perl fails to execute sybase stored procedure

Time:03-24

I am getting started using perl and sybase. i am trying to execute a stored procedure

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;

The connection is ok, but when I try to execute the stored procedure i get

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.

Removing use strict and warning i get.

DBI::st=HASH(0x55ad3d830630)->bind_param(...): attribute parameter 'SQL_INTERGER' is not a hash ref at ./sybase_test.pl line 16.

CodePudding user response:

It is not SQL_INTERGER, it is SQL_INTEGER. As listed in the documentation.

You should know that removing use strict doesn't solve problems, it hides them. It might feel comforting, but it doesn't help.

CodePudding user response:

You can use instead:

$sth->bind_param(1,5374,4);
$sth->bind_param(2,1,4);
$sth->execute;
  • Related