Re: Cursors... what's the alternative?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: BobMcClellan (bobmcc_at_tricoequipment.com)
Date: 03/24/04


Date: Wed, 24 Mar 2004 14:27:50 -0500

Richard,
first of all.. thanks for the reply....

my reason for the cursor is so i can use the recordset.
...
you say to generate a recordset in the stored procedure....

I was doing this via ado prior to opting to handle it entirely inside the
stored procedure
and was using the ado recordsets but how do you open a recordset inside the
stored procedure....

could you please provide a brief example of what the code would look like.
--------------------------------------------------------------------------
from the Front End .... i was using something like. . .
Dim rs As ADODB.Recordset
Set rs = CurrentProject.Connection.Execute("RS_slsMnByJob_MarkedForPrnt")

rs.MoveFirst
While Not rs.EOF

  MsgBox rs.Fields("LastName")
  rs.MoveNext

Wend
Set rs = Nothing
--------------------------------------------------------------------------
If i could open recsets in the sp and loop
that would work for me... i just thought it was accomplished by using a
cursor.

thanks in advance,
bob....

"Richard J" <anonymous@discussions.microsoft.com> wrote in message
news:56656FB5-9B11-4089-AB04-65EFD554BDE4@microsoft.com...
> Bob,
>
> Well, without getting to involved in reading your stored procedure, one
alternative to cursors is to simply generate a recordset in the stored
procedure and once returned to the application, loop through the returned
recordset and do whatever business logic necessary on each record.
>
> Hope this provides a little food for thought.



Relevant Pages

  • Re: vbscript logon script getting return data from sql sp
    ... Loop ... > One way to retrieve values from a stored procedure is with a Recordset ...
    (microsoft.public.scripting.vbscript)
  • Re: ADO Performance
    ... sections (this will vary a little depending on cursor location): ... Find out how long it takes to run the query and get the recordset ... place some logic on the server side to reduce the execution time. ... loop with oRS.MoveNext command. ...
    (microsoft.public.vb.general.discussion)
  • Re: vbscript logon script getting return data from sql sp
    ... > One way to retrieve values from a stored procedure is with a Recordset ... then the Do Until adoRecordset.EOF loop above loops ...
    (microsoft.public.scripting.vbscript)
  • Re: using adOpenDynamic
    ... Are you sure a default forward-only cursor won't do the job for ... Set objRS = CreateObject ... Loop ... response.write "Recordset was empty" ...
    (microsoft.public.inetserver.asp.db)
  • Re: problem while creating/acessing temp tables through ADO
    ... Because of that declaration, the recordset never got ... de-referenced between passes through the loop, and, since the connection ... using Execute rather than Open: ... If all you want is a server-side, forward-only cursor, then Execute is ...
    (microsoft.public.data.ado)