动态游标

来源:互联网 发布:淘宝七天无理由退货 编辑:程序博客网 时间:2024/04/30 14:23
 create or replace procedure RL_SZJC_ADDNEWistmp_flag number;tmp_now date;strSql varchar2(1000);--next_id number;tmp_rec RL_SZJC%ROWTYPE;type dy_cursor is ref cursor;cur_a dy_cursor;begin select max(trunc(TJYF,'YYYY')) into tmp_now from RL_SZJC; select nvl(max(flag),1) into tmp_flag from RL_SZJC where trunc(TJYF,'YYYY')=tmp_now; if tmp_flag<12 then      strSql:='select ID,GMCJ,KM,TJYF,FLAG from RL_SZJC where trunc(TJYF,''YYYY'')=(select max(trunc(TJYF,''YYYY'')) from RL_SZJC) and flag='||tmp_flag;      dbms_output.put_line(strSql);      OPEN cur_a FOR strSql;      LOOP          fetch cur_a  into tmp_rec;          exit when cur_a%notfound;                END LOOP;      CLOSE cur_a; end if;--exception --when others then --rollback;end RL_SZJC_ADDNEW;