oracle类型不匹配,sys_refcursor的使用,报错类型不匹配
---------------------------------------------------------------------------------------------------------------以下是數據源
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as scott@ORCL
SQL> desc dept1;
Name? ?Type? ?? ?? ?Nullable Default Comments
------ ------------ -------- ------- --------
DEPTNO NUMBER(2)? ? Y
DNAME??VARCHAR2(14) Y
LOC? ? VARCHAR2(13) Y
SQL> select * from dept1;
DEPTNO DNAME? ?? ?? ? LOC
------ -------------- -------------
10 ACCOUNTING? ???NEW YORK
20 RESEARCH? ?? ? DALLAS
30 SALES? ?? ?? ? CHICAGO
40 OPERATIONS? ???BOSTON
-----------------------------------------------------------------------------------------------------------以下是定義 type 和存儲過程
create type p_table is object (??----------類型1
deptno NUMBER(2) ,
dname??VARCHAR2(14),
loc? ? VARCHAR2(13)
);
create type use_p_table is table of p_table; -----------類型2
create or replace procedure up_test(o out sys_refcursor) is ----存儲過程1
begin
open o for select * from dept1;
end;
create or replace procedure use_sys_ref is -------- 存儲過程2
o sys_refcursor;
test_table use_p_table;
begin
up_test(o);
fetch o bulk collect into test_table;
for i in 1..test_table.count loop
dbms_output.put_line(test_table(i).deptno||''||test_table(i).dname||''||test_table(i).loc);
end loop;
end;
--------------------------------------------------------------------------------------------------------------------------------以下是調用
begin
use_sys_ref;
end;
----------------------------------------------------------------以下是報錯
ora-06504
l/sql:結果集變量或查詢的返回類型不匹配
總結
以上是生活随笔為你收集整理的oracle类型不匹配,sys_refcursor的使用,报错类型不匹配的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 三套方案!华为P60系列设计图曝光 前置
- 下一篇: linux下des加密命令,linux下