local oCursor oCursor=create("mycursor") oCursor.cStatement="select * from mytable into cursor zz" {lots of code here} return *------------ define class myCursor as custom cAlias="" cStatement="" procedure fill execscript(this.cStatement) this.cAlias=alias() endproc procedure destroy use in select(this.cAlias) endproc enddefineSince oCursor is local, it will be destroyed when your procedure exits. You can add a lot of other stuff to the class, of course - have it index the cursor etc etc.