Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One SPT cursor to be used in another SPT
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
Database:
MS SQL Server
Miscellaneous
Thread ID:
01135239
Message ID:
01135242
Views:
18
This message has been marked as the solution to the initial question of the thread.
>Hi Borislav
>
>>>I have 2 SQL SELECT statements, executed one by one. The problem arise when I wanted to use the returned cursor of the first SPT in the second. The backend is SQL server.
>>>
>>>How can I acheive this? Please advise.
>>
>>How to use it?
>>To update something or you want to use it to filtering data?
>
>It is more like further JOINing. I mean the first SPT uses a few backend tables and creates a cursor in VFP. The second one again does a SPT, but this time the just created cursor is JOINed with another backend table to create a second cursor to be used seperately.
>
>Hope this is what you wanted to know.

You can't do that.
SPT cursor (or any other VFP Table/Cursor) is not visible to SQL Server, you can't pass it as Parameter. You could save it to a table and join it with using T-SQL OPENROWSET() function, but this is slooooow :o)
You could do this joing two ways:
1. Use derived table with exact the same SELECT as first SPT cursor:
TEXT TO lcFirstCursorSelect NOSHOW TEXTMERGE
     SELECT ....
            FROM .....
            WHERE ....
ENDTEXT

TEXT TO lcSecondCursorSelect NOSHOW TEXTMERGE
     SELECT ....
            FROM .....
     JOIN (<<lcFirstCursorSelect>>) TblFrst ON .......
     WHERE ....
ENDTEXT
2. Select records w/o joining and than select jojned records using both SPT cursors in VFP.
I personaly prefer first suggestion, because it is faster and you get all records you need directly.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform