PL/SQL 十进制数转任意进制
Posted thenbz3
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PL/SQL 十进制数转任意进制相关的知识,希望对你有一定的参考价值。
很简单
SET SERVEROUTPUT ON SIZE 99999;
DECLARE
total integer;
y NUMBER ;
i NUMBER ;
n NUMBER := #
x NUMBER := &zh;
j NUMBER := 1;
s NUMBER := 1;
a VARCHAR2(100) := '';
type ruanchar IS VARRAY(1000) OF VARCHAR2(1);
type ruannum IS VARRAY(1000) OF NUMBER(2);
nums ruanchar;
sznums ruannum;
BEGIN
nums := ruanchar('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');
sznums := ruannum();
i := 1;
WHILE s!=0 LOOP
s := trunc(n/x);
y := MOD(n,x);
sznums.EXTEND;
sznums(i) := y;
i := i+1;
n := s;
END LOOP;
total := sznums.count;
FOR j in 1 .. total LOOP
a := a||nums(sznums(total-j+1)+1)||'';
END LOOP;
dbms_output.put_line(a);
END;
/
以上是关于PL/SQL 十进制数转任意进制的主要内容,如果未能解决你的问题,请参考以下文章