Perl - 如何调用Oracle DB存储过程

时间:2016-04-18 11:51:24

标签: oracle perl

我正在尝试执行存储过程,并且(现在)获取返回的行数。 但我不断收到以下错误:

DBD::Oracle::st execute failed: ORA-00900: invalid SQL statement (DBD ERROR: OCI
StmtExecute) [for Statement "exec VSU22.DB_API.GetUsersInfo(?);" with ParamValue
s: :p1=1] at C:\NNInstall\auit.pl line 19.

这是脚本:

#!/usr/bin/perl
use strict;
use dbi;

my ($connection_string, $nn_dbh, $extract_sth);
my $dbIPAddress = "192.168.147.55";
my @row;
my $query_result=0;
my $var;
$connection_string = "dbi:Oracle:host=$dbIPAddress;sid=NNVSDB";
$nn_dbh->{RaiseError} = 1;
$nn_dbh->{RowCacheSize} = 256;
$nn_dbh = DBI->connect($connection_string, 'DBSUER', 'DBUSER')
    or die "Connection failed: $DBI::errstr";

$extract_sth = $nn_dbh->prepare('exec DBUSER.API.UsersInfo(?);');
$extract_sth ->bind_param(1, 1);
my $num_ofOrows= $extract_sth->execute();

我做错了什么?

1 个答案:

答案 0 :(得分:1)

EXEC[CUTE]SQL*Plus command。它通常不在其他SQL客户端中实现。您可能需要使用匿名PL / SQL块;

BEGIN
    DBUSER.API.UsersInfo(?);
END;