CREATE OR REPLACE Function GetFtpSeqNO(riqi in Varchar2,
JiaoYLX in Varchar2) return Varchar2 is
pragma autonomous_transaction;
MaxBianH Varchar2(50);
begin
Lock Table MTJY_BianHTable In Exclusive Mode;
select MAX(ShangPBH)
into MaxBianH
from MTJY_BianHTable
where substr(Charshj, 1, 10) = riqi
and leix = JiaoYLX;
if MaxBianH is null then
case
when JiaoYLX = 'N' then
MaxBianH := 'CONT' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
when JiaoYLX = 'S' then
MaxBianH := 'SETT' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
when JiaoYLX = 'C' then
MaxBianH := 'COMP' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
when JiaoYLX = 'X' then
MaxBianH := 'ORDER' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
when JiaoYLX = 'Y' then
MaxBianH := 'FLWUP' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
when JiaoYLX = 'HBHK' then
MaxBianH := 'HBHK' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
when JiaoYLX = 'YJFL' then
MaxBianH := 'YJFL' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
when JiaoYLX = 'TB' then
MaxBianH := 'TB' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
when JiaoYLX = 'QR' then
MaxBianH := 'QR' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
when JiaoYLX = 'PZ' then
MaxBianH := 'PZ' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
when JiaoYLX = 'ZJMMXG' then
MaxBianH := 'ZJMMXG' ||
to_char(to_date(riqi, 'yyyy-MM-dd'), 'yyyyMMdd') ||
'00001';
end case;else
case
when JiaoYLX = 'N' then
MaxBianH := 'CONT' ||
trim(to_char(to_Number(substr(MaxBianH,
5,
13)) + 1,
'0000000000000'));
when JiaoYLX = 'S' then
MaxBianH := 'SETT' ||
trim(to_char(to_Number(substr(MaxBianH,
5,
13)) + 1,
'0000000000000'));
when JiaoYLX = 'C' then
MaxBianH := 'COMP' ||
trim(to_char(to_Number(substr(MaxBianH,
5,
13)) + 1,
'0000000000000'));
when JiaoYLX = 'X' then
MaxBianH := 'ORDER' ||
trim(to_char(to_Number(substr(MaxBianH,
6,
13)) + 1,
'0000000000000'));
when JiaoYLX = 'Y' then
MaxBianH := 'FLWUP' ||
trim(to_char(to_Number(substr(MaxBianH,
6,
13)) + 1,
'0000000000000'));
when JiaoYLX = 'HBHK' then
MaxBianH := 'HBHK' ||
trim(to_char(to_Number(substr(MaxBianH,
5,
13)) + 1,
'0000000000000'));
when JiaoYLX = 'YJFL' then
MaxBianH := 'YJFL' ||
trim(to_char(to_Number(substr(MaxBianH,
5,
13)) + 1,
'0000000000000'));
when JiaoYLX = 'TB' then
MaxBianH := 'TB' ||
trim(to_char(to_Number(substr(MaxBianH,
3,
13)) + 1,
'0000000000000'));
when JiaoYLX = 'QR' then
MaxBianH := 'QR' ||
trim(to_char(to_Number(substr(MaxBianH,
3,
13)) + 1,
'0000000000000'));
when JiaoYLX = 'PZ' then
MaxBianH := 'PZ' ||
trim(to_char(to_Number(substr(MaxBianH,
3,
13)) + 1,
'0000000000000'));
when JiaoYLX = 'ZJMMXG' then
MaxBianH := 'ZJMMXG' ||
trim(to_char(to_Number(substr(MaxBianH,
7,
13)) + 1,
'0000000000000'));
end case; end if;
insert into MTJY_BianHTable
(shangpbh, Charshj, Leix)
values
(MaxBianH, riqi || TO_char(sysdate, ' hh24:mi:ss'), JiaoYLX);
commit;
return MaxBianH;
exception
when others then
rollback;
return MaxBianH;
end GetFtpSeqNO;
SYSID NUMBER 编号;SHANGPBH VARCHAR2(50) 商品编号;CHARSHJ VARCHAR2(50) 插入时间; LEIX VARCHAR2(50)类型 ;