Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Moving between datasessions
Message
De
12/01/2008 05:22:37
 
 
À
11/01/2008 13:00:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01281189
Message ID:
01281318
Vues:
13
>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;
&&Your code in current session
.
.
.
&& Here you need data from another session
local oDataServer,oCur
oDataServer=createobject('oDataServerSession')
oCur=oDataServer.GetDataNeeded()
=cur2obj('myResultCursor')

select myResultCursor
browse normal
&&Use this cursor 
.
.




&&& Separate session which will extract data
&&& and serve them back as object
 
define class oDataServerSession as session   &&Private Sesssion
    
   procedure init
      this.open_tables()

      procedure open_tables
      && 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
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform