- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Oracle 12c。在 PL/SQL 我可以做到这一点
set serveroutput on
declare
begin
for x in (select 1 as y from dual) loop
dbms_output.put_line(x.y);
end loop;
end;
set serveroutput on
declare
cursor c1 is
select 1 as y from dual;
begin
for x in c1 loop
dbms_output.put_line(x.y);
end loop;
end;
set serveroutput on
declare
cur sys_refcursor;
begin
cur := Package.GetData(1234);
fetch cur into y;
while cur%FOUND loop
dbms_output.put_line(y);
fetch cur into y;
end loop;
end;
set serveroutput on
declare
cur sys_refcursor;
begin
cur := PACKAGE.GetData(1234); -- This returns a sys_refcursor
for x in cur loop
dbms_output.put_line(x.y);
end loop;
end;
Error report -
ORA-06550: line 5, column 16:
PLS-00221: 'cur' is not a procedure or is undefined
最佳答案
SYS_REFCURSOR
只是一个预先声明的弱引用游标。没有这样的机制来循环 sys_refcursor
不取。此外,您不能将弱 refcursor 与普通游标进行比较,它们的工作方式不同。它是一个缓冲区空间,用于临时保存结果。当您在 PLSQL
中运行以下语句时块,PLSQL
引擎不明白 PLSQL
变量并抛出错误
for x in cur loop
PLS-00221: 'CUR' is not a procedure or is undefined
OUT
如果它重新返回
SYS_REFCURSOR
,则将参数添加到包中.
cur := PACKAGE.GetData(1234);
SYS_REFCURSOR
的内容然后显示如下:
declare
a SYS_REFCURSOR;
v_emp_id employee.emp_id%type;
begin
--- This is a procedure with OUT parameter as SYS_REFCURSOR
dynmc_selec(emp_output=>a);
loop
FETCH a INTO v_emp_id;
EXIT WHEN a%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(v_emp_id );
end loop;
end;
关于plsql - PL SQL For 循环 Sys_RefCursor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42698175/
我会打电话 procedure或 function从 java 使用 JDBC . 在最佳实践和性能方面,最好使用 function返回 SYS_REFCURSOR或使用 procedure返回 SY
我可以使用普通游标的值打开 sys_refcursor 吗? create or replace procedure test(C1 out sys_refcursor) Lv_c1 as
我可以使用普通游标的值打开 sys_refcursor 吗? create or replace procedure test(C1 out sys_refcursor) Lv_c1 as
CREATE OR REPLACE PROCEDURE GetEmployeesInDept( c OUT SYS_REFCURSOR) 我有一个与上述存储过程相关的查询,也就是说,在定义光标
甲骨文 11g 这似乎比它应该的更难,所以我可能在这里走错了路。 我有一个生成用户定义表单的应用程序,我的数据比这更复杂,但想法是——我有一个数据表,其中包含从用户定义的表单输入的所有数据 creat
我有一个带有选择值的游标,我想在取决于我是否找到任何行之后做一些事情。 recs_Table SYS_REFCURSOR; begin open recs_Table for s
我有点被困在这里了。我在 Oracle 中有一个愚蠢的小函数,并尝试用 Java 访问它。返回值应该是 SYS_REFCURSOR。但如果我尝试用 Java 调用它,就会出现错误。 这是 Oracle
下面的 W.r.t 代码我不能将 fetch-into-variable 的类型声明为基础表的 %ROWTYPE,因为 SYS_REFCURSOR 位于连接两个表的选择上,并且还选择了一些在基础两个表
我正在使用 Oracle 12c。在 PL/SQL 我可以做到这一点 set serveroutput on declare begin for x in (select 1 as y from
所以我有一个存储过程ONE create or replace PROCEDURE ONE ( A in number B in number ... ZZ out SYS_R
我正在使用 Oracle 12g,并尝试从 SYS_REFCURSOR 获取 ResultSet 我有一个带有以下签名的过程: CREATE OR REPLACE PROCEDURE proc_sea
这可能有点傻,但我想知道这是否可能。 我有一个返回 sys_refcursor 的函数 CREATE OR REPLACE FUNCTION get_employee_details(p_emp_no
我正在尝试通过 Entity Framework 访问 Oracle 11g 上的存储过程。我可以访问返回标量和返回正确值的存储过程。但是当使用 SYS_REFCURSOR 用于返回结果集,函数导入时
我有一个 PL/SQL 包,它根据您传递的 id 返回一个 sys_refcursor。我想遍历一些 id 并创建一个新的 ref 游标,其中包含为每个 id 重复的原始结果集中的一列。 (类似于交叉
我的包体中有一个过程: create or replace package body MYPACKAGE is procedure "GetAllRules"(p_rules out
我正在尝试使用 PLSQL 存储过程获取行,并将它们保存到 JPA 实体中。我正在使用ojbdc7 , spring-boot-starter-data-jpa和spring-boot 2.2.1 .
我的包体中有一个过程: create or replace package body MYPACKAGE is procedure "GetAllRules"(p_rules out
是否可以在 plsql 中执行动态 sql 并将结果返回到 sys_refcursor 中?到目前为止,我已经粘贴了我的尝试,但无法正常工作,这是我通过我的 java 应用程序遇到的错误 ORA-01
我想使用 JPA 调用带有 SYS_REFCURSOR 的过程,如 OUT 参数。使用普通 JDBC 非常容易,但我不确定这在 JPA 中是否可行。 我的程序如下: CREATE OR REPLACE
我有一个像这样的(简化的)Oracle SQL: declare xd number; xm number; DataOut sys_refcursor; begin xd := to
我是一名优秀的程序员,十分优秀!