create function DBA.getxkzh(in vvalue char(16))
returns char(50)
deterministic
begin
declare xhzk char(50);
declare ls_char char(1);
declare x integer;
declare y integer;
declare z integer;
declare v integer;
set xhzk='';
set ls_char=substring(vvalue,8,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,3,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,10,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-20),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,15,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,1,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,3,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-28),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,7,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,15,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,8,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-31),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,10,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,14,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,3,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-22),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,7,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,11,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,16,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-37),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,14,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,9,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,1,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-25),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,11,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,2,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,6,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-7),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,2,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,6,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,10,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-24),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,3,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,1,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,12,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-16),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,9,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,7,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,1,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-18),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,13,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,4,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,7,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-4),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,2,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,14,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,1,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-19),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,13,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,15,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,9,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-39),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,12,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,1,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,2,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-12),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,16,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,8,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,11,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-15),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,3,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,11,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,7,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-26),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,11,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,2,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,14,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-34),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,2,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,11,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,7,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-27),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,6,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,7,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,16,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-23),100);
set xhzk=xhzk+ordertochar(v);
set ls_char=substring(vvalue,12,1);
set X=ASCII(ls_char);
set ls_char=substring(vvalue,2,1);
set Y=ASCII(ls_char);
set ls_char=substring(vvalue,11,1);
set Z=ASCII(ls_char);
set v=mod(abs(X*Y+Z-13),100);
set xhzk=xhzk+ordertochar(v);
return xhzk
end
有用到了另外一个函数 ordertochar(),在上面找到了该函数
create function DBA.chartoorder(in id char(20))
returns char(50)
deterministic
begin
declare rvalue char(50);
declare li_len integer;
declare i integer;
declare ls_char char(1);
set rvalue='';
set li_len=datalength(id);
set i=1;
while i <= li_len loop
set ls_char=substring(id,i,1);
set rvalue=rvalue+trim(str(ASCII(ls_char)));
set i=i+1
end loop;
return rvalue
end