RE: Remote View Inlist Parameterized where clause

Author: Chuck Urwiler

Posted: 2002-11-08 at 09:35:09

Dan,

Unfortunately, I'm pretty sure you can't do what you're trying, since

SQL Server doesn't have an allowable syntax for this. In other words,

what SQL Server is getting is the following statement:=20

Select * from table where field in ( @p1 )

And there's no way for SQL Server to "expand" what you put into @p1,

which is the SQL Server side of the ?vp_list you're specifying. All this

will accept is a single value, no comma-delimited list acceptable here.=20

Alternatives: how many distinct values are you looking for? Could you do

this:=20

Select * from table where field =3D ?vp_p1 or field =3D ?vp_p2

Or, better yet, can you do this with data from the server? For example,

imagine that this query gets you the list (from the server) that you're

looking for:=20

Select field from othertable where somecondition =3D somevalue

(returns cursor with 'A','B','C')

Then you could send this:=20

Select * from table where field in (select field from other table where

somecondition =3D somevalue)

Instead of trying to parameterize the statement.=20

-Chuck Urwiler, MCT, MCSD, MCDBA

http://www.eps-software.com

> -----Original Message-----

> From: Dan Neuman [mailto:dneuman@pclv.com]=20

> Sent: Thursday, November 07, 2002 7:52 PM

> To: Multiple recipients of ProFox

> Subject: Remote View Inlist Parameterized where clause

>=20

>=20

> I have a question for the SQL Server remote view gurus.

>=20

> I need to create a remote view to a SQL database, and in the=20

> where clause I

> would like to provide a list of values. And if the field=20

> matches one of

> those values, then return the record.

>=20

> Is there a way to do that?

>=20

> Something like:

> Local vp_List

> vp_List =3D ["A","B","C"]

> Use RemoteViewName

>=20

>=20

> Remote View SQL Statement:

> Select Table.* from dbo.Tablename where=20

> inlist(Tablename.Field, ?vp_List)

>=20

>=20

>=20=20

©2002 Chuck Urwiler