CREATE OR REPLACE FUNCTION fn_fco_Random
(
    pch_clave IN char
)
RETURN number
IS
    vnm_seed number;
    i number;
begin
    vnm_Seed := TO_NUMBER(TO_cHAR(SYSDATE, 'SSSSS'));
    
    i := 1;
    WHILE i <= Length(pch_clave)
    LOOP
        vnm_Seed := vnm_Seed + Ascii(Substr(pch_clave, i, 1));
        i := i + 1;
    END LOOP;

    vnm_Seed := MOD(vnm_Seed * 22695477,  (2 ** 32));
/*   dbms_output.put_line(MOD(BITAND(vnm_Seed/(2 ** 16), 32767), 10000));*/
    RETURN MOD(BITAND(vnm_Seed/(2 ** 16), 32767), 10000);
end;
/
CREATE PUBLIC SYNONYM fn_fco_Random FOR ADAM.fn_fco_Random;
GRANT ALL ON fn_fco_Random TO ADAMA;
