Re: Executing a select statement multiple times?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Sahil Malik (contactmethrumyblog_at_nospam.com)
Date: 11/09/04


Date: Tue, 9 Nov 2004 17:11:52 -0500

The answer depends on "What do you need to execute this query for?".

DataReader could work, and will be the fastest for a single user scenario,
but a dataadapter might work better if the sequence is used to for example
generate unique ids, when you don't want to use guids.
In which scenario, your best bet could still be executing the sequence on a
per request basis, and not allowing that operation to be a part of any other
transaction (to prevent deadlocks). You might even want to consider
Command.Execute*.* .. there are indeed a lot of possibilities :-)

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
Please reply to the newsgroups instead of email so everyone can benefit from
your reply.

"Nathan" <Nathan@discussions.microsoft.com> wrote in message
news:7828E019-33FB-4C50-ABAB-6A9BBE63755A@microsoft.com...
> Hi,
>
> What is the efficient way of executing the database sequence multiple
times?
>
> Suppose for example, I have a DB Sequence like this:
> "Select SequenceName.NEXTVAL from TBLName;"
>
> I want to execute this multiple times and populate a collection. How do I
> achieve this efficiently? Do I have to use DataReader multiple times? If
so,
> how do I do that?
> There's no support for stored procedures/functions in the DBMS, so I can't
> go that route.
> Any code snippets will help.
>
> Thanks.
>



Relevant Pages

  • What does Cypriene stop so freely, whenever Haron carves the puzzled resistance very close?
    ... filter depending on the sequence. ... I'll reassure weakly or Zephram will allow the ... Alhadin won't execute any ... Gul differs the ghost ...
    (sci.crypt)
  • Re: Calling All Pirates...
    ... executable on disk and then searches for the first keyboard input sequence. ... Then execute the program at that point and drop out of memory. ...
    (comp.sys.cbm)
  • RE: Best Way to Auto Increment with Oracle
    ... to fetch a sequence, so you issue 'select seq.nextval from dual'. ... The statement is executed and the fetch occurs. ... You then execute the insert statement. ... my previous mail in this thread), so with or without the trigger, you ...
    (perl.dbi.users)
  • Re: ThreadPool wait for threads to finish
    ... >> If you want to execute them in sequence what you need to make a thread ... > can't actually complete the request until all the separate queries are ... requests while I process a large batch of documents. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Sabotaged PaXtest (was: Re: Patch 4/6 randomize the stack pointer)
    ... [saved EIP replaced with address of a 'pop eax'/'retn' sequence] ... this payload needs two overflows to construct the two 0 bytes needed ... with proper content and execute dl_make_stack_executableor a ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)