create or replace procedure RL_SZJC_ADDNEW
is
tmp_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;