CREATE OR REPLACE FUNCTION IDFMS.func_dec236 (parm IN INT DEFAULT 0)
RETURN VARCHAR2
IS
/*
10进制数转36进制数
*/
src VARCHAR2 (36) := ‘0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ‘; --改成其它字符串,就是任意进制
LEN INT;
res VARCHAR2 (10) := ‘‘;
tmp INT;
val INT;
BEGIN
tmp := parm;
len := LENGTH (src);
WHILE (tmp >= 36)
LOOP
val := MOD (tmp, len);
res := SUBSTR (src, val + 1, 1) || res;
tmp := TRUNC (tmp / len);
END LOOP;
IF (tmp >= 0)
THEN
res := SUBSTR (src, tmp + 1, 1) || res;
END IF;
RETURN res;
END;
/
时间: 2024-11-08 06:23:41