I have a dynamic SQL SELECT statement generated using a PL/SQL code.
declare
sql_query clob;
begin
sql_query := 'select * from ...........';
execute immediate sql_query;
end;
I want to retrieve the output of the above dynamically generated SELECT statement into an array in Perl. What I have already tried in Perl is,
$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";
}
And the error I'm getting is,
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.
I'm a newbie for PL/SQL and I'm not sure if I have followed the proper path. Can someone please advise me on this?
Thanks in advance!
-- Shaakunthala