字母数字组合进位 F_Comm_NumLetterCarry
create or replace function F_Comm_NumletterCarry(v_char in varchar2)
return varchar2 is
Result varchar2(1);
const_num_letter char_table;
i number;
begin
const_num_letter := new char_table('0', '1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z');
i := 1;
while i <= const_num_letter.count loop
if const_num_letter(i) = v_char then
exit;
end if;
i := i + 1;
end loop;
if i = const_num_letter.count then
Result := const_num_letter(1);
elsif i > const_num_letter.count then
Result := '';
else
Result := const_num_letter(i + 1);
end if;
return Result;
end F_Comm_NumletterCarry;
/
字母数字组合自增 F_Comm_IncreaseNumLetter
create or replace function F_Comm_IncreaseNumLetter(code in varchar2)
return varchar2 is
Result varchar2(100);
newCode varchar2(100);
v_char_table char_table;
v_char varchar2(1);
isCarry number;
i number;
begin
v_char_table := f_comm_splitstr(upper(code));
i := v_char_table.count;
newCode := '';
while i >= 1 loop
if i = v_char_table.count then
-- 是否进位
if v_char_table(i) = 'Z' then
isCarry := 1;
else
isCarry := 0;
end if;
-- 加 1
v_char := f_comm_numlettercarry(v_char_table(i));
else
if isCarry = 1 then
v_char := f_comm_numlettercarry(v_char_table(i));
else
v_char := v_char_table(i);
end if;
-- 是否再进位
if v_char_table(i) = 'Z' then
if isCarry = 1 then
isCarry := 1;
end if;
else
isCarry := 0;
end if;
end if;
newCode := v_char || newCode;
i := i - 1;
end loop;
if isCarry = 1 then
newCode := isCarry || newCode;
end if;
Result := newCode;
return Result;
end F_Comm_IncreaseNumLetter;
/
