REF 动态SQL游标

declare 
  tb_count number;
  tb_datatype varchar2(100);
  type refcur_finding is ref cursor;--ref 动态游标创建
  refcur refcur_finding;
  codevalue varchar2(100);
begin 
  tb_datatype := '财险';
  
  /*验证是否在信息集范围内*/
  dbms_output.put_line('===★★★★★★=====验证非空字段中是从数据字典中取数的字段【开始】=====★★★★★★====');
  --员工基本信息集【性别】字段数据字典信息校验
  open refcur for    --为查询的SQL动态打开游标
  select C_GENDER from (
     select C_GENDER from tb_inf_employee group by C_GENDER   
  ) a left join (
     select c_Code from tb_sys_codeitem where c_typecode = 'CODE_GenderType' 
  ) b 
  on a.c_gender = b.c_code where b.c_code is null;
  loop   
        fetch refcur into codevalue;
        exit when refcur%notfound;
        dbms_output.put_line('01 【员工基本信息集】中【性别】信息与数据字典信息比较后,发现多出【'||codevalue||'】');
  end loop;
  dbms_output.put_line('-------员工基本信息集【性别】字段校验完成---------');
  --select t.rowid,t.c_gender,t.c_oid from tb_inf_employee t where t.c_gender is null ;
  
   dbms_output.put_line('===★★★★★★=====验证非空字段中是从数据字典中取数的字段【结束】=====★★★★★★====');
  dbms_output.put_line(tb_datatype||'--数据验证结束');
end;


猜你喜欢

转载自peter2009.iteye.com/blog/1969925
ref