Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Object reference lost in SQL SELECT ?
Message
De
09/05/2006 10:40:46
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows Server 2003
Network:
Windows 2003 Server
Divers
Thread ID:
01120146
Message ID:
01120347
Vues:
17
Hi Igor

PMFJI, but I advise you not to access objects/properties in this way.

When you say SELECT column1 FROM table1 the values of column1 are expected to differ throughout the table. The object's property may be fixed. If it is, the overhead VFP has to locate the property in the object is undesirable. This overhead is worse when access or assigns are added to the property. Imagine trying to debug why you're suddenly having a massive slowdown in a query in another part of the app, just because you added an access/assign to a simple property. The overhead is even worse the longer the chain object.property is faster than object1.object2.property.

If it is not fixed the results you get may be undesirable. I suggest only directly accessing the property when you know the property content will vary or you want to fire an access method. Try m.object1.object2.property1 unless you can use THISFORM.object1.object2.property1.

Otherwise, do as Nadya said. Create a simple string including the content of the property and execute that string. Use TEXT...ENDTEXT as it's cleaner. I demonstrated using TEXT...ENDTEXT at the last Toronto Ontario FoxPro User's Group meeting, while presenting my snippet factory.

>I have the following SQL SELECT statement:
>
>
>   cSQLStatement = "SELECT column1, column2, alltrim(object1.object2.property1) as column3 FROM cursor1 INTO CURSOR cursor2 READWRITE"
>
>
>I execute it by using:
>
>
>   &cSQLStatement
>
>
>The problem is that very often for no reason I get an error message "ALIAS object2 is not found". It sometimes works, and sometimes doesn't. Object variable "object1" is declared in the method, it has a member property "object2" properly created, as well as character member property "property1" properly created. If I check the value of object1.object2.property1 before or after the statement, I get a correct value.
>
>At the same time, if I create property "property1" as a member of "object1", then this allways works (i.e. the expression would be ...alltrim(object1.object2.property1)...).
>
>Real names of columns, properties, cursors and objects references are quite unique in my testing and they are not reserved words, so I could exclude this part.
>
>Does anyboby have suggestions on what could be causing this behaviour.
>
>The environment is: VFP 9, SP1, W2003 Server, MTDLL.
>
>Thanks you!
>Igor.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform