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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to clean a cursor for reuse.

Status
Not open for further replies.

chi1

Programmer
Jan 15, 2003
3
US
I am interested know how to clean a cursor in order to reuse it with another set of data. I have a cursor full of data and at some point in the program I need to clean the whole cursor and fill that up with totally new data. I know how to delete a row from the cursor but don't know how to delete everything from it. Any tip witll be helpful. Thanks.

 
if used('MyCursor')
Sele MyCursor
use in MyCursor
endif

this way, you removed the cursor, and then you can recreate it....

Please let me know if this helped you :)

Tekno
Wireless Toyz
Ypsilanti, Michigan
 
Or briefer:

USE IN SELECT('MyCursor')

Let me elaborate on what TeknoSDS said. CURSOR is short for CURrent Set Of Records. Or, a subset of the original. So when you close the cursor as in USE, it goes away. It then has to be recreated if it is to be reopened.
Dave S.
 
Nice, Dave, you found something shorter than what I use:

USE IN ( iif(used('MyCursor'),0,'MyCursor') )

Correction, "What I used"!
 
I'm all for saving keystrokes!
I forget where I saw that or I would have given proper credit. It may have been here or it may have been Advisor. Dunno.
Dave S.
 
Hi

1. In order to create a new set of data in an existing cursor, simply do a REQUERY() or doan SQL SELECT.
When a REQUERY() is done on a view or an SQL SELECT is done on an otherwise cursor, the table is closed automatically and so the current record set is lost and then the new record set is opened as per the latest query/SQL statements. There is not even a need for closing a cursor and opening it.

2. To simply close a cursor.. USE IN myCursor.. will do it.
By closing you loose all the record set in that cursor.

:)
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top