The first part
--36 10 Binary
Create or Replace function f_36to10(STR varchar)returnintIs
ReturnValueint;
STR36 varchar(36);
Subwork varchar(1);
Workindexint;
Lenint;
Iint;
Begin
returnvalue:=0;
STR36: =' 123456789Abcdefghijklmnopqrstuvwsyz‘;
I: =1;
Len: = length(Trim(Str));
whileI <= Len Loop
Subwork: = SUBSTR(STR, I,1);
Workindex: = InStr(Str36,subwork,1,1);
ReturnValue: = ReturnValue +(Workindex * Power(len-i));
I: = i + 1;
end Loop;
return returnvalue;
end F_36to10;
Part II
--10 36 Binary
Create or Replace function f_10to36(Iint)returnVARCHAR is
RET VARCHAR2(8);
Var_mint;
var_sint;
Begin
RET: =‘‘;
var_s: = i;
whilevar_s >=36Loop
Var_m: = MoD(var_s,36);
ifVar_m <10Then
RET: = To_char(Var_m)|| Ret
Else
RET: = CHR(Var_m-10+97)|| Ret
Endif;
var_s: = trunc(var_s/36);
End Loop;
ifvar_s >0Or(var_s =0and ret =‘‘)Then
ifvar_s <10Then
RET: = To_char(var_s)|| Ret
Else
RET: = CHR(var_s-10+97)|| Ret
Endif end if ;
&NBSP;&NBSP;
return upper (ret;--lpad (ret, 8, ' 0 ' ) ;
&NBSP;&NBSP;
END&NBSP;F_10TO36;
< Span style= "color: #ffffff;" >< Span style= "color: #000000;" >< Span style= "color: #000000;" > Another method, Link: http://www.cnblogs.com/jak-black/ archive/2010/09/25/1834617.html
ORACLE 36 binary and 10 binary, reciprocal conversion functions