Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use VFP cursor IN SPT query?
Message
From
13/09/2002 04:18:29
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00699905
Message ID:
00700066
Views:
12
Lynda,

If your VFP cursor contains only a few records, the easiest is probably to use Claudio's suggestion of building a T-SQL command. However, if you have a lot of records, then I would use the temp table approach. In fact I use this approach in my SPT class. Example:
*-- build a VFP cursor with some keys
SELECT customer_id AS customerId;
 FROM (HOME()+"Samples\Tastrade\Data\customer.dbf");
 WHERE customer.country="US";
INTO CURSOR CustKeys
*-- upload the keys to a temp SQL Server table
o.copyVfpToBackend("CustKeys", "#CustKeys", "CustomerId", .f., "CustomerId", .f., .t.)
*-- join the customers table with the uploaded temp table to
*-- only retreive the customers that were selected in VFP
SQLEXEC(o.inSql, "SELECT * FROM customers INNER JOIN #custKeys ON customers.customerId=#custKeys.customerId")
Here's what the method copyVfpToBackend() does in pseudo code:

- generate CREATE TABLE script based on < tcVfpTable >
- CREATE #Temp TABLE
- Read empty #temp table and convert it into an updatable SPT cursor
- append the data from the VFP cursor/table inot the updatable SPT cursor
- TABLEUPDATE()

With regards to user rights, I believe that a default user should be able to create temp tables on SQL Server.

HTH

>Is there a way to select records from a SQL Server table based upon values in a VFP cursor using SPT? In concept its simply....
>
>SELECT * from SQLTable Where PK IN (Select PK from VFPCursor)
>
>but since SQL doesn't know the contents of the VFP cursor, it's obvious why this won't work. Is some other way -- other than Scan the cursor and retrieve them one at a time...
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform