我正在尝试通过数据库链接调用存储过程。代码看起来像这样:
declare
symbol_cursor package_name.record_cursor;
symbol_record package_name.record_name;
begin
symbol_cursor := package_name.function_name('argument');
loop
fetch symbol_cursor into symbol_record;
exit when symbol_cursor%notfound;
-- Do something with each record here, e.g.:
dbms_output.put_line( symbol_record.field_a );
end loop;
CLOSE symbol_cursor;
当我从 package_name 所属的同一个数据库实例和模式运行它时,我可以正常运行它。但是,当我通过数据库链接运行它时(对存储的过程名称进行必要的修改等),我收到一个 oracle 错误:ORA-24338:未执行语句句柄。
此代码在 dblink 上的修改版本如下所示:
declare
symbol_cursor package_name.record_cursor@db_link_name;
symbol_record package_name.record_name@db_link_name;
begin
symbol_cursor := package_name.function_name@db_link_name('argument');
loop
fetch symbol_cursor into symbol_record;
exit when symbol_cursor%notfound;
-- Do something with each record here, e.g.:
dbms_output.put_line( symbol_record.field_a );
end loop;
CLOSE symbol_cursor;