0

I'm trying to generate a Random String using PL/SQL with only 2 fixed words. It's this possible?

1
  • What do you mean by "only 2 fixed words"? Can you give an example (update the question)? Commented Apr 9, 2019 at 18:32

1 Answer 1

1

Is this what you're looking for?

SQL> with
  2  -- two fixed words
  3  test as
  4    (select 'fixed words' col from dual),
  5  -- split them to rows
  6  inter as
  7    (select level lvl, regexp_substr(col, '.', 1, level) let
  8     from test
  9     connect by level <= length(col)
 10    )
 11  -- aggregate them back, randomly
 12  select listagg(let, '') within group (order by dbms_random.value(1, max_lvl)) result
 13  from inter
 14  join (select max(lvl) max_lvl from inter) on 1 = 1;

RESULT
--------------------------------------------------------------------------------
reiosdwxf d

SQL> /

RESULT
--------------------------------------------------------------------------------
fe ixoddrws

SQL> /

RESULT
--------------------------------------------------------------------------------
 wdxeorsdfi

SQL>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.