Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Generating unique values without triggers/sequences

Re: Generating unique values without triggers/sequences

From: Mark J. Bobak <mark_at_bobak.net>
Date: 19 Jul 2002 20:32:14 -0700
Message-ID: <fe9b0e1b.0207191932.28800ce8@posting.google.com>


No triggers or sequences? Not sure if you can get there from here.

However, I may be able to help with the character datatype problem.

Some (probably more complex) variation of this: SQL> select chr(ascii('A')+1) from dual

C
-
B

may do the trick. But then you have to worry about what to do when you get to 'Z'? 'AA'? How would you code it? Some interesting challenges there, but perhaps this gets you pointed in the right direction?

Idea: Do you know how BASE64 encoding works? If you just need characters in the range A-Z, think in terms of BASE26. A-Z and a-z would be BASE52 add in 0-9, you're up to BASE62. I'm not sure what the other two characters are that BASE64 utilizes.

I know, sounds a little on the wild side, but, by your own admission, the restrictions were pretty ridiculous.

-Mark

laredotornado_at_zipmail.com (D. Alvarado) wrote in message news:<9fe1f2ad.0207191324.672f59f2_at_posting.google.com>...
> Hello,
> (oracle 8.1.7) Due to the seemingly ridiculous restrictions I've
> put on this problem, it may not be possible to do this, but here goes:
> I'm looking for a way (in an INSERT statement) to generate unique
> values for a column either of a numeric or VARCHAR type. If it was
> just numeric, this would be basically straightforward:
>
> MAX(NUMERIC_FIELD) + 1
>
> but writing a more generic version to accommodate VARCHAR is more
> complicated. I discovered "MAX" is supported on VARCHAR's, but sadly,
> "+ 1" is not, for obvious reasons.
>
> Any ideas would be greatly appreciated.
>
> Thanks, Dave A.
Received on Fri Jul 19 2002 - 22:32:14 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US