Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FoxPro Select query with joins to Sql Server tables?
Message
From
10/04/2013 13:04:57
 
 
To
10/04/2013 12:33:09
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01570621
Message ID:
01570638
Views:
51
With only 8 records in the cursor, I would select the matching records in a loop, a la
Select yourcursor
lnX=1
Scan
   lcVar = yourcursor.field1
   Sqlexec(lnHandle,'Select * from yourtable where yourfield = ?lcVar','curDummy' + transform(lnX))
   lnX = lnX + 1
Endscan
This will give you the necessary cursors which you can merge with a loop of Select * from .. Union all ..




>>Get your Jobs and Users into local cursors and then join with them locally.
>
>The Sql Server table 'Jobs' has 43,000 rows in it and I need to join them with a local cursor that has about 8 rows in it to find the 8 matching records in 'Jobs' based on a lookup field.
>
>So, are you telling me I habe write one Sql Server query to pull over all 43,000 rows to a local cursor, then write a FoxPro select to join them to the other existing local cursor?
>
>Yikes!!! That's ugly.
>
>
>
>
>>>How do write a Select where you need to join a local (pre-existing) cursor with one or more tables from the Sql Server??
>>>
>>>In this example below from my current DBF-based app, lcCsrMtlRecords is a local cursor and I need join it to some lookup values that need to come from my Sql Server database (Jobs and Users).
>>>
>>>
>>>Select Users.email ;
>>>	From (lcCsrMtlRecords) ;
>>>		Join Jobs On Jobs.job_num = &lcCsrMtlRecords..mat_code ;
>>>		Join Users On Jobs.quoted_by = Users.emp_num ;
>>>	Where qty_recd <> before_qty_recd ;
>>>	Order By 1 ;
>>>	Group By 1 ;
>>>
>>>
>>>
>>>
>>>
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform