Hello,
I have written the following SQL function for generating a random UUID:
CREATE OR REPLACE FUNCTION GENERATE_UUID
RETURN VARCHAR2
IS
uuid VARCHAR2(255 BYTE);
BEGIN
uuid:= lower(dbms_random.string('X', 8) || '-' || dbms_random.string('X', 4) || '-' || dbms_random.string('X', 4) || '-' || dbms_random.string('X', 4) || '-' || dbms_random.string('X', 12));
RETURN uuid;
EXCEPTION
WHEN OTHERS THEN RAISE_APPLICATION_ERROR(-20501, 'An error was encountered! - '||SQLCODE||' -ERROR- '||SQLERRM);
END;
/
show errors
The thing that I must do, is to use the DEFINE keyword and assign a random UUID from the function call to a variable RANDOM_UUID. But none of the ways I tried work:
DEFINE RANDOM_UUID = GENERATE_UUID;
or
DEFINE MERCHANTID = EXEC GENERATE_UUID;
Your help is much appreciated! Thanks in advance!