How does one generate an upper and lowercase alphanumeric random string from oracle?
I have used select DBMS_RANDOM.STRING(\'x\', 10) from dual
to generate
CREATE OR REPLACE FUNCTION fn_mac RETURN varchar2 IS
w number :=0;
a varchar2(10);
b varchar2(50);
x number :=0;
y number :=0;
z number :=0;
c varchar2(50);
result varchar2(20);
BEGIN
select round(dbms_random.value(1,99))into w from dual;
SELECT upper(dbms_random.string('A', 2))into a FROM dual;
SELECT round(dbms_random.value(1, 9)) into x FROM dual;
SELECT upper(dbms_random.string('A', 4)) into b FROM dual;
SELECT round(dbms_random.value(1, 9)) into y FROM dual;
SELECT upper(dbms_random.string('A', 1)) into c FROM dual;
SELECT round(dbms_random.value(1, 9)) into z FROM dual;
result :=( to_char(w) ||a|| to_char(x)|| b|| to_char(y)|| c ||to_char(z)) ;
DBMS_OUTPUT.PUT_LINE( 'Result ::' || result);
RETURN result ;
END fn_mac;
/