Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Command line length
Message
De
22/08/2011 09:02:20
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01521401
Message ID:
01521469
Vues:
60
>>
>>And you can return more than one cursor (which people usually forget). I got some pieces of code where I send a string containing a very long series of SQL commands, which returns between 11 and 23 cursors in one go.
>
>It's maintenance nightmare because there's no way to tell what data each returned cursor holds by its name. It's the same as working with work areas using their number instead of an alias.

For such cases, I prepend a field, like this:
SELECT   '+' AS crsMycursor	;
			,	mytable.* ...
and then I have a little routine for that:
			FOR i = 0 TO nRet - 1
				THIS.ReAlias("x" + ALLTRIM(TRANSFORM(i, "@Z 99")))
			ENDFOR
...
...
	PROCEDURE ReAlias(tcFrom, tcTo)
		tcTo = EVL(tcTo, FIELD(1, tcFrom))
		IF USED(tcFrom)
			USE IN SELECT(tcTo)
			USE DBF(tcFrom) IN 0 ALIAS (tcTo) AGAIN
			USE IN SELECT(tcFrom)
		ENDIF
Of course, most of the time I don't supply the 2nd parameter at all - that's for a couple of special cases left over from previous versions.

In the end, this extra work paid off in speed of pulling the cursors, specially that almost all of them are related to a temp table that I'd probably have to recreate, or take extra pain to kill, each time. The speed is crucial, because I have to run this quite often, and my time scores high on my list (lazy programmer of the 2nd kind, I am).

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform