Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursor INNER JOIN with client server table
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
01038183
Message ID:
01038266
Views:
13
Michel,

There are a few things wrong with the code I sent below. In the SQL section, the double quotes (") should be replaced with a single quote (') and the space at the end of each string should be moved to the beginning of the next string since varchar will truncate the extra spaces at the end. Also, a string of 500 IDs will most likely be too long to pass to SQL as a single string, so you may have to pass it as multiple strings to multiple parameters and then just put back together inside the SP. But, I hope you get the idea.

HTH,
Chad

>Oh, if it's just 500 IDs, I would just pass them up as a single comma delimited string and use it as an IN clause. So, build your list something like this:
>
>LOCAL lcList as String
>
>lcList = ''
>
>SCAN
>	lcList = lcList + ',' + TRANSFORM(idField)
>ENDSCAN
>
>SQLEXEC(lnHandle, 'execute StoredProcName ' + SUBSTR(lcList, 2), 'curResult')
>
>Then, your stored proc could look something like this:
>
>CREATE PROCEDURE dbo.joinProc
>	(
>		@idList varchar(2000) = ""
>	)
>as
>	set nocount on
>
>	declare @query varchar(2500)
>
>	set @query = "SELECT table1.fieldList, table2.fieldList "
>	set @query = @query + "FROM table1 "
>	set @query = @query + "INNER JOIN table2 "
>	set @query = @query + "ON table1.id = table2.id "
>	set @query = @query + "WHERE table2.id IN (" + @idList + ")"
>
>	execute (@query)
>return
>
>Be aware that build queries to execute like this is a bit harder to debug, but it works great when you need dynamicly built queries.
>
>HTH,
>Chad
>>The cursor is 500 IDs. It is really small. It is just a cursor for the primary keys. Then, I can use that to collect all the related fields from the table.
>>
>>Could you provide an example on how I could accomplish that?
_________________________________
There are 2 types of people in the world:
    Those who need closure
Previous
Reply
Map
View

Click here to load this message in the networking platform