Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to generate alpha-numeric sequence in Oracle?
kranilk_at_gmail.com wrote:
> Hello All,
>
> After searching the web unsuccessfully for what I am looking for, I
> have come here.
> I need to generate a 6 digit alpha-numeric sequence of values that
> looks like the following.
> 00001A
> 00001B
> :
> 00001Z
> 00002A
> 00002B
> :
>
> Do any of you know how to generate the above using sequence in Oracle?
> Any information and/or pointers will be very helpful to me. And, of
> course, any sample code would be greatly appreciated. I mainly work in
> Java. We are using Oracle 9i.
>
> Thanks in advance for all the help.
>
You could do this programmatically by creating your own function. An Oracle sequence will only generate integer values. However, you can extend this. Think of hexadecimal....with values from 0 to 9 and A to F. If you were given a decimal integer, you would easily write a routine to convert it to hex. Just do the same thing, but the values are from 0 to 9 and A to Z. Store your code in a function. Have that code get the sequence's next value and the do the conversion.
HTH,
Brian
-- =================================================================== Brian Peasland dba_at_nospam.peasland.net http://www.peasland.net Remove the "nospam." from the email address to email me. "I can give it to you cheap, quick, and good. Now pick two out of the three" - UnknownReceived on Tue Oct 31 2006 - 14:33:13 CST