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: more than one number from sequence

Re: more than one number from sequence

From: Volker Apelt <gq437x_at_yahoo.de>
Date: 24 Oct 2002 10:28:48 +0200
Message-ID: <lgbs5kdyv3.fsf@mu.biosolveit.local>


Daniel Morgan <dmorgan_at_exesolutions.com> writes:

> Volker Apelt wrote:
>
> > I'm looking for a way to retrieve more than one id
> > per SQL statement/OCI aall from a sequence.
> >
> Not from dual.
 

> 1. Create a table with 1,000,000 rows.
> 2. Use a random number generator to generate a random number.
> 3.
> SELECT sequence_name.NEXTVAL FROM tablewiththreerows WHERE rownum <
> randomnum+1;

Thanks, I'll use the 'helper table' approach without PL/SQL.  

> And you will get what you want. Though why you would want it is a mystery to
> me. Because I can't imagine how you are going to SELECT INTO a random number
> of variables.

Not a _random_ number of ID's. I need a _different_ number of IDs each time.

I'll have to bulk insert into four tables about 200, 6000, 6000, 6000 related rows every 5 seconds from many clients. So, we try to prefetch the ID's, assign them, setup the foreign key relations and assamble the records at the client side. We can't draw ID's one by one. And we don't want to setup the foreign key relations with SQL queries.

Bye,

Volker

-- 
Volker Apelt                   
Received on Thu Oct 24 2002 - 03:28:48 CDT

Original text of this message

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