I have this code that is working perfectly, but I need random values to appear in place of X. I want the returned result to be composed of random letters and that the position of uppercase and lowercase letters be obeyed according to the user input in the function at the time of the tests. I use this function to "shuffle" people's names. The first name is preserved and I want the rest of the name to appear in random characters.
Example:
- Input:
Pedro Souza
- Result
Pedro Fscet
The amount of letters should remain the same and should be case sensitive.
Does anyone know how I can do this? I am using SQL DEVELOPER.
create or replace FUNCTION EMBARALHA_NOME (NOME IN VARCHAR2) RETURN VARCHAR2 AS
primeiro_Nome VARCHAR2(100);
embaralha VARCHAR2(100);
nome_Cortado VARCHAR2(100);
nome_Embaralhado VARCHAR2(100);
BEGIN
if (NOME is NULL) then
nome_Embaralhado := NULL;
else
primeiro_Nome := NVL(SUBSTR(NOME, 0, INSTR(NOME, ' ')-1), NOME);
nome_Cortado := LTRIM(NOME, primeiro_Nome);
embaralha := REGEXP_REPLACE(nome_Cortado, '[A-Za-z]', 'x');
nome_Embaralhado := CONCAT(primeiro_Nome, embaralha);
end if;
return nome_Embaralhado;
END EMBARALHA_NOME;