--versiones 8i
CREATE OR REPLACE FUNCTION DIGDEC(X IN VARCHAR2) RETURN NUMBER IS
   vDigito Number(2);
BEGIN
   Select Decode(X, '0', 0, '1', 1, '2', 2, '3', 3, '4', 4, '5', 5, '6', 6, 
                 '7', 7, '8', 8, '9', 9, 'A', 10, 'B', 11, 'C', 12, 'D', 13, 
                 'E', 14, 'F', 15)
      Into vDigito
   From Dual;

   Return vDigito;
END DIGDEC;
/

CREATE OR REPLACE FUNCTION DIGHEX(X NUMBER) RETURN VARCHAR2 IS
   vCaracter Varchar2(1);
BEGIN
   Select Decode(X, 0, '0', 1, '1', 2, '2', 3, '3', 4, '4', 5, '5', 6, '6', 
                 7, '7', 8, '8', 9, '9', 10, 'A', 11, 'B', 12, 'C', 13, 'D', 
                 14, 'E', 15, 'F')
      Into vCaracter
   From Dual;

   Return vCaracter;
END DIGHEX;
/
