Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

random username

Tony007Apr 26 2013 — edited Apr 26 2013
hi i have a situation in my application where i have to create random username if the username which is been entered already exist in database so for example if i what to enter tJames but already exist can i suggest tJames001 tJames003 and so on something like this have anyone write pl/sql like that
something like this

create or replace function RandomString(p_Characters varchar2, p_length number)
    return varchar2
    is
      l_res varchar2(256);
    begin
      select substr(listagg(substr(p_Characters, level, 1)) within group(order by dbms_random.value), 1, p_length)
        into l_res
        from dual
      connect by level <= length(p_Characters);
     return l_res;
   end;

but it must check the username which is been try to be entered and create randon username based on that
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 24 2013
Added on Apr 26 2013
23 comments
472 views