我有一个SELECT
使用 PL/SQL 代码生成的动态 SQL 语句。
declare
sql_query clob;
begin
sql_query := 'select * from ...........';
execute immediate sql_query;
end;
我想将上述动态生成的SELECT
语句的输出检索到 Perl 中的数组中。我已经在 Perl 中尝试过的是,
$sql = "declare
sql_query clob;
begin
sql_query := 'select * from ...........';
execute immediate sql_query;
end;";
$sql_prep = $dbh->prepare($sql) or die "Cannot prepare.";
$sql_prep->execute() or die "Cannot execute.";
while (@row = $sql_prep->fetchrow_array ()) {
print "@row\n";
}
我得到的错误是,
DBD::Oracle::st fetchrow_array failed: ERROR no statement executing (perhaps you need to call execute first) [for Statement "declare
........
........
"] at ./script.pl line 60.
我是 PL/SQL 的新手,我不确定我是否遵循了正确的路径。有人可以给我建议吗?
提前致谢!
——沙昆塔拉