【发布时间】:2021-03-01 07:36:58
【问题描述】:
我创建了一个 oracle 游标以促进并发性。这是我的光标。
create or replace FUNCTION get_unlocked_records RETURN table_to_test%ROWTYPE IS
CURSOR c IS SELECT * FROM table_to_test where status_code = 5 FOR UPDATE SKIP LOCKED;
record_to_get table_to_test%ROWTYPE;
BEGIN
OPEN c;
FETCH c INTO record_to_get;
CLOSE c;
RETURN record_to_get;
END;
当我使用这些命令在 2 个单独的 sql 会话中进行测试时,会出现以下错误。
declare
record_to_gets table_to_test%ROWTYPE;
begin
exec :record_to_gets := get_unlocked_records;
dbms_output.put_line(record_to_gets);
end;
错误
Error starting at line : 32 in command -
declare
record_to_gets table_to_test%ROWTYPE;
begin
exec :record_to_gets := get_unlocked_records;
dbms_output.put_line(record_to_gets);
end;
Error report -
ORA-06550: line 4, column 7:
PLS-00103: Encountered the symbol "" when expecting one of the following:
:= . ( @ % ;
The symbol ";" was substituted for "" to continue.
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
我在这里做的错误是什么?
既然我的最终目标是在java中调用函数并得到结果,那么如何调用这个函数来获取java中的第一条记录呢?
提前致谢。
【问题讨论】:
标签: oracle plsql oracle11g stored-functions