Perl DBD :: SQLAnywhere在运行存储过程时挂起

时间:2015-01-14 09:34:56

标签: perl sqlanywhere

我们在SQL Anywhere 11上运行了一个旧的遗留应用程序。在迁移到新软件时,我们首先在遗留系统上进行数据验证。 我使用perl来自动执行此过程。

首先将存储过程添加到数据库,然后执行它,最后从表中选择结果。

现在 使用perl代码创建SP - 好的 使用perl代码执行SP - NOK 在sql编辑器中运行SP,然后使用perl代码获取结果 - 确定

当我尝试从perl代码执行SP时,脚本会挂起。

脚本:

#!/usr/bin/perl -w
use strict;
use DBI;
use File::Slurp;
use Data::Dumper;

my $dbh;

sub createConnection{
  my $uid = shift;
  my $pwd = shift;

  my $conn = DBI->connect("DBI:SQLAnywhere:ENG=ENG_NAME",
          "UID=$uid;PWD=$pwd;DBN=dbn;LINKS=tcpip(host=IP;port=port)") or die "Cannot connect to database: $DBI::errstr\n";

  return $conn;
}

sub createProcedure{
    my $procedure = read_file('data_check.sql', binmode => ':utf8');

    $dbh->do($procedure);
}

sub executeProcedure{
    my $sth = $dbh->prepare('CALL prDataCheck(?,?,?);');
    $sth->bind_param(1, '2014-01-14');
    $sth->bind_param(2, 'FSK');
    $sth->bind_param(3, 'Y');
    $sth->execute();

}

sub getResult{
     my $sth = $dbh->prepare('select * from result_table;');
     $sth->execute();
    my $response = $sth->fetchrow_hashref();
    print Dumper $response . "\n";

}


$dbh = createConnection("xxx", "yyy");

createProcedure();
executeProcedure();
getResult();





END{
  $dbh->disconnect;
}
  exit(0);

我试图以各种方式执行SP:

首次尝试

$dbh->do("CALL prDataCheck('2014-01-14','FSK','Y');")

第二次尝试

my $sth = $dbh->prepare('CALL prDataCheck(?,?,?);');
$sth->bind_param(1, '2014-01-14');
$sth->bind_param(2, 'FSK');
$sth->bind_param(3, 'Y');
$sth->execute();

我在尝试执行脚本时尝试设置DBI-> trace(3): 但没有太多的

Executing Procedure ..
Go ..
    -> prepare for DBD::SQLAnywhere::db (DBI::db=HASH(0x28042c8)~0x2804208 'call prDataCheck(?,?,?);') thr#2342010
scanned 3 distinct placeholders
    <- prepare= ( DBI::st=HASH(0x2804550) ) [1 items] at dataCheck.pl line 29 via  at dataCheck.pl line 59
executing
    -> execute for DBD::SQLAnywhere::st (DBI::st=HASH(0x2804550)~0x2804268 '2014-01-13' 'FSK' 'Y') thr#2342010
         bind :p1 <== '2014-01-14' (type 0)
Binding input hostvar ':p1' to ordinal 1
         bind :p2 <== 'FSK' (type 0)
Binding input hostvar ':p2' to ordinal 2
         bind :p3 <== 'Y' (type 0)
Binding input hostvar ':p3' to ordinal 3

行为与我用于执行的方法相同。

我在运行脚本时也尝试使用strace,但输出并没有多说。 它似乎在等待......

semop(4816896, {{0, -1, SEM_UNDO}}, 1)  = 0

有人可以帮我解释一下吗? 我有点卡住.. 我尝试针对sqlanywhere11和sqlanywhere16中的SDK编译DBD :: SQLAnywhere。

氪 马库斯

1 个答案:

答案 0 :(得分:0)

您可能需要提交更改。我想这是一个交易问题。