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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Distinct Random Number Generation

Re: Distinct Random Number Generation

From: TurkBear <johng_at_mm.com>
Date: Fri, 15 May 1998 16:46:35 GMT
Message-ID: <355d6fbe.10698103@news2.mm.com>


"Matthew D. Heilman" <matthew.d.heilman_at_ac.com> wrote:

>Here is the scenario. I want to generate a unique number so I can assign it
>as the indentifier of some attribute. I have a table that looks like:
>
>product_ID NUMBER(10) --Primiary key
>product_descr VARCHAR2(255)
>
>So, each time I have a new product_descr I want to assign it a unique
>product_ID. I was planning to have the font end generate a random number(or
>even have oracle do it) and then check if this number already exists in the
>table. But I do not want to have to query the table each time to see if a
>newly generated random number exists. I also can not use a counter, because
>I will be deleting products and I may run out of number eventually(I will be
>processing HUGE amounts of products).
>
>Any suggestions?
>
>
>

It would seem to be an ideal case for an Oracle Sequence

Hope it helps,
John Greco
Oracle DBA Received on Fri May 15 1998 - 11:46:35 CDT

Original text of this message

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