精选30+云产品,助力企业轻松上云!>>>
CURSOR是强类型,SYS_REFCURSOR 是弱类型(类似C#的var)。
Cursor:
create or replace package pkg ascursor cur isselect 1 n from dual;type tcur is ref cursor return pkg.cur%rowtype;end pkg;/--类型报错declarecur pkg.tcur;beginopen cur forselect \'a\' s, 1 n from dual; --跟游标定义的类型不一致end;/--正常运行declarecur pkg.tcur;beginopen cur forselect \'kkk\' n from dual;end;/--正常运行declarecur pkg.tcur;beginopen cur forselect 900 n from dual;end;/
View Code
Sys_refcursor:
declarecur sys_refcursor;beginopen cur forselect \'a\' s, 1 n from dual;close cur;open cur forselect 9 n from dual; --跟上面的游标类型不一致close cur;end;/