Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursor INNER JOIN with client server table
Message
 
To
03/08/2005 14:20:35
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
01038183
Message ID:
01038245
Views:
23
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
Next
Reply
Map
View

Click here to load this message in the networking platform