Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Increment Field
Message
From
11/04/2008 18:33:02
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01309981
Message ID:
01310116
Views:
22
>Hi Al,
>
>You shouldn't use an alias in RECNO() or similar functions because a query always uses internal alliases for tables involved. If you do, than you reference an alias outside of a query.

Sure, that's what my testing just showed. Even explicitly calling the alias of the derived query tries to go outside (my Test #2). It just shows that these two overloads of RECNO() have different behaviour.

>>
>>* Test2
>>CLOSE DATABASES ALL
>>
>>CREATE CURSOR Test1 ( Char1 C( 10 ) )
>>* We purposefully leave no rows in the first cursor
>>
>>CREATE CURSOR Test2 ( Char1 C( 10 ), OrderCol I )
>>INSERT INTO Test2 ( Char1, OrderCol ) VALUES ( "One", 1 )
>>INSERT INTO Test2 ( Char1, OrderCol ) VALUES ( "Two", 2 )
>>INSERT INTO Test2 ( Char1, OrderCol ) VALUES ( "Three", 3 )
>>INSERT INTO Test2 ( Char1, OrderCol ) VALUES ( "Four", 4 )
>>INSERT INTO Test2 ( Char1, OrderCol ) VALUES ( "Five", 5 )
>>
>>* Purposely set the currently selected table to
>>* the first cursor instead of Test2 to see if we can fool RECNO():
>>SELECT Test1
>>
>>SELECT ;
>>  * ;
>>  , RECNO( "DerivedTable" ) AS MyRecNo ;
>>  FROM ;
>>    ( SELECT ;
>>      * ;
>>      FROM Test2 ) DerivedTable ;
>>  INTO CURSOR Output ;
>>  ORDER BY OrderCol
>>
>>* Result: Program error: "Alias is not found". But, we're explicitly referencing
>>the alias of the derived table! Shouldn't this work? < g >
>>
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform