>We have several routines which run SQL SELECT statements against tables which may or may not already be open. In addition, they may open an unknown number of additional cursors (cur(1), cur(2),...cur(n) depending on the data.
>
>It might be better to write a cleanup routine but I was wondering if it is possible to open a new datasession, do the processing there, move the resulting cursor to the main datasession, and then close the new datasession.
>
>So............Is there a simple way to copy a cursor from one datasession to another?
>
>Thanks......Rich
Hi Rich,
If resulting set is smaller in size then have look at FAQ#29297
It parses cursor as object between data sessions.
It boils down to using 2 function calls.
oCur=Cur2Obj('SourceCursor')
Parse this to another session (or obtain from another session or form object)
And then simply call counterfunction ;
=Obj2Cur(oCur,'ResultCursor')
Will also transfer memo fields if you have any.
Here is usage sample;
.
.
.
local oDataServer,oCur
oDataServer=createobject('oDataServerSession')
oCur=oDataServer.GetDataNeeded()
=cur2obj('myResultCursor')
select myResultCursor
browse normal
.
.
define class oDataServerSession as session
procedure init
this.open_tables()
procedure open_tables
procedure GetDataNeeded
.
select ..... from .... into myCursor
return obj2cur('myCursor')
enddefine
Of course before uing it you need to dump actual code from FAQ to some of your prg libraries.
HTH
Sergio