--versiones 10g
CREATE OR REPLACE FUNCTION DIGDEC(X IN VARCHAR2) RETURN NUMBER IS
BEGIN
   RETURN CASE X 
             WHEN '0' THEN
                0
             WHEN '1' THEN
                1
             WHEN '2' THEN
                2
             WHEN '3' THEN
                3
             WHEN '4' THEN
                4
             WHEN '5' THEN
                5
             WHEN '6' THEN
                6
             WHEN '7' THEN
                7
             WHEN '8' THEN
                8
             WHEN '9' THEN
                9
             WHEN 'A' THEN
                10
             WHEN 'B' THEN
                11
             WHEN 'C' THEN
                12
             WHEN 'D' THEN
                13
             WHEN 'E' THEN
                14
             WHEN 'F' THEN
                15
          END;
END DIGDEC;
/

CREATE OR REPLACE FUNCTION DIGHEX(X NUMBER) RETURN VARCHAR2 IS
BEGIN
   RETURN CASE X 
             WHEN 0 THEN
                '0'
             WHEN 1 THEN
                '1'
             WHEN 2 THEN
                '2'
             WHEN 3 THEN
                '3'
             WHEN 4 THEN
                '4'
             WHEN 5 THEN
                '5'
             WHEN 6 THEN
                '6'
             WHEN 7 THEN
                '7'
             WHEN 8 THEN
                '8'
             WHEN 9 THEN
                '9'
             WHEN 10 THEN
                'A'
             WHEN 11 THEN
                'B'
             WHEN 12 THEN
                'C'
             WHEN 13 THEN
                'D'
             WHEN 14 THEN
                'E'
             WHEN 15 THEN
                'F'
          END;
END DIGHEX;
/
