Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a cursor 1

Status
Not open for further replies.

risslsu

Programmer
Jan 13, 2004
18
0
0
US
How do I close an SQL Server generated cursor?

I am currently trying:

CLOSE xCursorName
REALLOCATE xCursorName

Program Error when the follwing code is reached:
IF USED('xCursorName')
SELECT xCursorName
USE
ENDIF

This error lead me to believe that the cursor is not released. Any help

Thank You,
Marissa
 
Your syntax looks correct if you the name of the cursor is in fact xCursorName

* Your syntax
IF USED('xCursorName')
SELECT xCursorName
USE
ENDIF

However, if xCursorName is a variable containing the name of the cursor try this:

* New syntax
IF USED('&xCursorName')
SELECT (xCursorName)
USE
ENDIF


* You may not need the & on the USE statement, but I believe it will work for sure with it.

Jim Osieczonek
Delta Business Group, LLC
 
Marissa,

Just to add to Jim's good advice, basically you close a SPT-gnerated cursor in exactly the same way as a normal VFP cursor.

USE IN xxx

That usuall does it, where xxx is the alias of the cursor. If you don't know if the cursor is still open, any of Jim's methods should hit the spot.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Marissa,

A quick tip that I picked up from MikeLewis awhile back is to use:

USE IN SELECT('xCursorName')

...instead of:

IF USED('xCursorName')
SELECT xCursorName
USE
ENDIF


Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top