ref cursor 可以作为C#的数据库接口,但是在plsql中如何引用呢:举一个例子:
set serveroutput on ;
declare
v_tab_name varchar2(20);
v_version varchar2(10);
v_tab_crt_str varchar2(2000);
v_tab_col_name varchar2(50);
v_tab_col_type varchar2(50);
v_cons_flg varchar2(1);
type cust_cursor is ref cursor;
tab_crt_cur cust_cursor;
begin
v_tab_name:='screlation';
open tab_crt_cur
for 'select version,name,name2,value ,cons_flg from changemanagementddl where name='''||v_tab_name||'''';
fetch tab_crt_cur into v_version, v_tab_name, v_tab_col_name, v_tab_col_type,v_cons_flg;
v_tab_crt_str:='create table '||v_tab_name||'( ';
while tab_crt_cur%found
loop
if v_cons_flg='1' then
v_tab_crt_str:=v_tab_crt_str||v_tab_col_name||' '||substr(v_tab_col_type,instr(v_tab_col_type,',')+1)||',';
else
v_tab_crt_str:=v_tab_crt_str||v_tab_col_name||' '||v_tab_col_type||',';
end if ;
fetch tab_crt_cur into v_version, v_tab_name, v_tab_col_name, v_tab_col_type,v_cons_flg;
end loop;
v_tab_crt_str:=substr(v_tab_crt_str,1,length(v_tab_crt_str)-1)||')';
close tab_crt_cur ;
dbms_output.put_line(v_tab_crt_str);
end;