Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting FROM/INTO same cursor
Message
De
06/08/2008 04:53:49
 
 
À
04/08/2008 18:32:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01336417
Message ID:
01336788
Vues:
13
>We have a module which creates a cursor and then returns its name. I need to further refine the selection but I'm getting an error that I'm hoping somebody here can explain.
>myCursor = thisform.get_some_date(params)
>this code works
>SELECT * from (myCursor) WHERE id IN ;
>  (SELECT id FROM (myCursor) WHERE condition);
>  INTO CURSOR DifferentName
>
>but this code
>SELECT * from (myCursor) WHERE id IN ;
>  (SELECT id FROM (myCursor) WHERE condition);
>  INTO CURSOR (myCursor)
>
>generates the Open Table dialog and then an error because it can't find the cursor (myCursor).
>
>It also works if I code it as
>SELECT id FROM (myCursor) WHERE condition INTO CURSOR curHold
>SELECT * FROM (myCursor) src;
>                  JOIN curHold ch ON ch.id = src.id;
>  INTO CURSOR (myCursor)
>
>I'm curious as to what causes MyCursor to close when using it for the FROM, IN( ), and INTO CURSOR.
>
>Any thoughts appreciated.

It is a VFP bug.
The VFP SQL Engine has an error:
VFP close the INTO CURSOR alias before to analyze the where condition.

A workaroud is to create another alias as source for the conditon subquery.
USE DBF(m.myCursor) again in 0 alias (m.myCursor+'_')
SELECT * from (m.myCursor) WHERE id IN ;
  (SELECT id FROM (m.myCursor+'_') WHERE condition);
  INTO CURSOR (m.myCursor)
USE IN (m.myCursor+'_')
Of course, it can produce side effects in your application.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform