日期:2014-05-16  浏览次数:20513 次

获取下次要插入的准考证号码
create or replace function njutec_getNextZkzCode(examyear in varchar2, sourcetype in varchar2,zyid in varchar2) return varchar2 is
    Result varchar2(100);
    pre_param01 varchar2(100);
    pre_param02 varchar2(100);
    ab varchar2(100);
    cd integer;
begin
    Result:='';
    pre_param01:=substr(examyear,3,4)||sourcetype||zyid||'00001';
    pre_param02:=substr(examyear,3,4)||sourcetype||zyid||'_____';
    select count(*) into cd from LTS_EXAM_SIGNUP where zkzcode = pre_param01;
   if cd = '0' then
     Result:=pre_param01;
   end if;
   if cd !='0' then
     select max(zkzcode)+1 into ab from LTS_EXAM_SIGNUP where zkzcode like pre_param02;
     Result:=ab;
   end if;
  return(Result);
end njutec_getNextZkzCode;