Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's wrong with this SELECT?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00025329
Message ID:
00026298
Views:
39
>>>>>>>SELECT ObjectID ;
>>>>>>>FROM Test t1;
>>>>>>>WHERE (not DELETED()) and (t1.ParentID IN ;
>>>>>>>(SELECT ObjectID FROM Test t2 WHERE DELETED()));
>>>>>>>INTO CURSOR ToDel
>>>>>>>
>>>>>>>Vlad
>>>>>>
>>>>>>SET DELETED is OFF
>>>>>>
>>>>>>I add the "= .T." to keep the SELECT more readable.
>>>>>>
>>>>>>I tryed your's but nothing is returned!
>>>>>>
>>>>>>What's wrong?
>>>>>
>>>>>Try to see if the inner SELECT returns something. It does not depend on the outer SELECT.
>>>>>
>>>>>Do you have deleted records in Test? :)
>>>>>
>>>>>Vlad
>>>>
>>>>Of course, one record is deleted.
>>>>
>>>>I try each parts of this select in "stand alone mode" and each of them work fine. But "team work" does not do the job...
>>>>
>>>>I think about some little pest with thousand of legs who play with my computer... :-(
>>>
>>>What if you put the INTO CURSOR before WHERE?
>>>
>>>Vlad
>>
>>Like is said to Barbara, i cut the select in two parts and now all is OK.
>>
>>What i think is there is a problem with the DELETED() in SELECT SQL subquery. Because i don't see nothing wrong with my SELECT and i expected somebody here have a response to my question:
>>
>>What is wrong with this select? ;-]
>
>
>For your pleasure only, there is the solution (select in 2 pieces):
>
>************
>LParameters lnObjectID
>
>SET DELETED OFF
>SELECT Test
>SET ORDER TO TAG OBJECTID
>SEEK lnObjectID
>IF FOUND()
>    DELETE
>    DO WHILE .T.
>        SELECT ObjectID FROM Test WHERE Deleted() INTO CURSOR TmpDel
>        SELECT DISTINCT Test.ObjectID ;
>            FROM Test,TmpDel WHERE !DELETED() ;
>            AND Test.ParentID IN (SELECT TmpDel.ObjectID ;
>            FROM TmpDel ) INTO CURSOR ToDel
>        IF _TALLY = 0
>            EXIT
>        ELSE
>            DELETE FROM Test ;
>                WHERE ObjectID IN(SELECT ObjectID FROM ToDel)
>        ENDIF
>    ENDDO
>ENDIF
>SET DELETED ON
>RETURN .T.
>
>****************************
>
>Now you see what i tried to do.
>Bye ;-)

Try the original select statement without the table being opened. Set deleted still needs to be off. Function in sql statements like DELETED() and RECNO() do not always work if the table is already open.
Previous
Reply
Map
View

Click here to load this message in the networking platform