日期:2014-05-16 浏览次数:20880 次
create or replace PROCEDURE SP_INSERT_XQ
(
xqmc in VARCHAR2(30),
ssqh in VARCHAR2(12)
)
AS
str_xqbm NUMBER;
jls NUMBER;
str_tmp VARCHAR2(2);
begin
select count(*) INTO jls from qh where sjqhbm=ssqh and substr(qhbm, 13, 2) <> '99' and qhjb=''6'
if(jls=0) then
insert into qh(qhbm,qhmc,sjqhbm,tbrq) values(ssqh+'01',xqmc,ssqh,SYSDATE);
else
select max(qhbm) into str_xqbm from qh where sjqhbm=ssqh and substr(qhbm, 13, 2) <> '99' and substr(qhbm, 13, 2) <> '98' an qhjb='6';
str_tmp := to_char(substr(str_xqbm,13,14))+1);
if length(str_tmp)=1 then
str_tmp :='0' +str_tmp;
end if;
insert into qh(qhbm,qhmc,sjqhbm,tbrq) values(ssqh+str_tmp,xqmc,ssqh,SYSDATE);
end if;
END SP_INSERT_XQ