- 论坛徽章:
- 0
|
闲着 给你写个。IDS7.31上测试通过。
create procedure dec(s1 varchar(255) )
returning decimal(20,0) ;
define ss varchar(255);
define tt char(1);
define result decimal(20,0);
define i integer;
let ss = lower(s1);
let ss = trim( both from ss );
if ( substr( ss, 1,1 ) = '0' and substr( ss,2,1 ) ='x' )
then
let ss = substr( ss,3 );
end if
let result = 0;
for i =1 to length ( ss )
let tt = substr( ss,i,1);
let result = result * 16 +
decode( tt,
'a',10,'b',11,
'c',12,'d',13,
'e',14,'f',15,
tt+0);
end for
return result ;
end procedure;
[ 本帖最后由 wenlq 于 2006-2-24 11:06 编辑 ] |
|