ORACLESYS_REFCURSORVSREFCURSOR

database

CURSOR是强类型,SYS_REFCURSOR 是弱类型(类似C#的var)。

Cursor:

createorreplace package pkg as

cursor cur is

select1 n from dual;

type tcur is ref cursorreturn pkg.cur%rowtype;

end pkg;

/

--类型报错

declare

cur pkg.tcur;

begin

open cur for

select"a" s, 1 n from dual; --跟游标定义的类型不一致

end;

/

--正常运行

declare

cur pkg.tcur;

begin

open cur for

select"kkk" n from dual;

end;

/

--正常运行

declare

cur pkg.tcur;

begin

open cur for

select900 n from dual;

end;

/

View Code

 

Sys_refcursor:

declare

cur sys_refcursor;

begin

open cur for

select"a" s, 1 n from dual;

close cur;

open cur for

select9 n from dual; --跟上面的游标类型不一致

close cur;

end;

/

 

以上是 ORACLESYS_REFCURSORVSREFCURSOR 的全部内容, 来源链接: utcz.com/z/534214.html

回到顶部