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!

How to best generate a unique alphanumeric key

Thomas MorganAug 7 2013 — edited Aug 10 2013

Hi:

  I have a requirement to generate a unique alphanumeric key 20 characters long.

  I know that I can use sys.dbms_random.string('X', 20) but I also have a requirement to not include certain characters that could be missread, i.e. no 0 (zero), O(uppercase oh) and a few others.

  My questions are:

     1) Is there a way to tell dbms_random to not include certain characters in the key generation

     2) If the answer to 1 is No, what would be the best way to replace the unwanted characters.  I am thinking just do a translate right afterwards with a randomly generated set of characters that do not include the characters I am interested in and seeded

         upon package initialization.  Any other ideas.

    3) Is there a better way of meeting this requirement within PL/SQL?

Thanks,

Thomas

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 7 2013
Added on Aug 7 2013
24 comments
18,633 views