如何解决从Perl脚本中的oracle storageprocedure的游标检索结果
我发现很难通过perl脚本从存储过程(oracle)中获取记录。 SP接受1个输入,输出参数为光标
--------这是perl脚本_-------------
my $dbh = DBI->connect("dbi:Oracle://**********",'**',***) or die "Couldn't connect to database: " . DBI->errstr;// successfully connected
my $cursorRecords;
my $categoryBind = 'tkuat';
my $sth= $dbh->prepare(q{
BEGIN
GetJobEnvironments(:category,:cursorTest);
END;
});
$sth->bind_param(":category",$categoryBind);
$sth->bind_param_inout(":cursorTest",\$cursorRecords,20000,{ ora_type => ORA_RSET});
$sth->execute or die "Can't execute SQL statement\n";
my @row=$cursorRecords->fetchrow_array();
print("row:@row\n");
print("cursorRecords:$cursorRecords\n");
print Dumper($sth);
script is executing but not printing the records from the database
---O/p:--------
row:
cursorRecords:DBI::st=HASH(0x1564318)
$VAR1 = bless( {},'DBI::st' );
------------------------------
SP in Database looks as below
create or replace PROCEDURE GetJobEnvironments
(
v_category IN CHAR DEFAULT NULL,v_cursor OUT SYS_REFCURSOR
)
AS
BEGIN
IF ( v_category IS NULL ) THEN
BEGIN
OPEN v_cursor FOR
SELECT EnvVar,VALUE
FROM JobEnvironments ;
END;
ELSE
BEGIN
OPEN v_cursor FOR
SELECT EnvVar,VALUE
FROM JobEnvironments
WHERE Category = v_category ;
END;
END IF;
EXCEPTION
WHEN OTHERS THEN raise_application_error(-20002,SQLCODE||':'||SQLERRM);
END;
表JobEnvironments
中也有一条记录
bind() $cursorRecords
中的引用可以保存表中的记录吗?
有人可以帮忙吗?
----表中的记录------
select * from JobEnvironments
Category,EnvVar,Value,last_update
-----------------------------------
tkuat','REUTFEED_SUBJ','RSF.REC',;\'2010-04-07 06:00:33.0'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。