Re: I think this is an SQL question... by AA
AA
Wed Apr 05 13:46:53 CDT 2006
Jeff,
You've run into a limitation imposed on subqueries in VFP: one can't use
expressions on both sides of the predicate.
Change the WHERE clause in the correlated subquery to
(... WHERE ;
FromControls.Folio=FromFactor.folio AND;
FromControls.Code =FromFactor.Code )
Looks and reads better too, I think.
-Anders
"Jeff Grippe" <jgrippe@hilldun.com> skrev i meddelandet
news:1235bi0fmtk490d@news.supernews.com...
> Tim,
>
> Thanks for the help.
>
> As I understood it, it didn't work. Here is the code that I used based on
> your response....
>
> SELECT ;
> * ;
> INTO CURSOR ;
> MissingFromControls ;
> FROM ;
> FromFactor ;
> WHERE ;
> NOT EXISTS ( ;
> SELECT ;
> 'X' ;
> FROM ;
> FromControls ;
> WHERE ;
> STR(FromControls.Folio,6,0) + FromControls.Code = ;
> STR(FromFactor.Folio,6,0) + FromFactor.Code ;
> )
>
> the error returned was SQL: Error correlating fields
>
> thanks again
>
> Jeff
>
> "Tim Witort" <trw7at@ixdot.netcomdotcom> wrote in message
> news:Xns979B5C38BBE88timwitortwrotethis@81.174.50.80...
>> Jeff Grippe seemed to utter in news:12353ev2jaupqf8@news.supernews.com:
>>
>>> Hello and thanks in advance for the help...
>>>
>>> I have two cursors which are the result of two different queries. Each
>>> table has the following fields:
>>>
>>> Folio N (6,0)
>>> Code C(4)
>>>
>>> In a perfect world they are identical. When the are not I need the
>>> following two additional cursors:
>>>
>>> All records in the first cursor that are missing from the second
>>> All records from the second cursor that are missing from the first
>>>
>>> Right now I'm doing this using an index: STR(FOLIO,6,0)+CODE for both
>>> tables.
>>> Then I setup a relation from one to the other: SET RELATION TO
>>> STR(FOLIO,6,0)+CODE INTO TWO
>>> Finally I use a copy command: COPY TO NOTINONE FOR FOLIO <> TWO.FOLIO
>>>
>>> This works but copy will only create tables. There doesn't appear to be
>>> a "COPY TO CURSOR"
>>>
>>> I imagine that this could be done with another SQL query but I'm not
>>> sure how to setup that query.
>>
>> SELECT * ;
>> INTO CURSOR NOTINTWO ;
>> FROM ONE ;
>> WHERE NOT EXISTS ( ;
>> SELECT 'X' ;
>> FROM TWO ;
>> WHERE STR(TWO.FOLIO,6,0)+TWO.CODE = STR(ONE.FOLIO,6,0)+ONE.CODE ;
>> )
>>
>> And the same in the other direction. There are a couple
>> different ways to get the same information.
>>
>> -- TRW
>> _______________________________________
>> t r w 7
>> at
>> i x dot n e t c o m dot c o m
>> _______________________________________
>
>