Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Equivalent of VFP INLIST with string of values
Message
De
27/11/2007 23:23:17
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01271536
Message ID:
01271647
Vues:
23
Del

I really did have a senior moment in forgetting how to do this with a view parameter behavior class. I have such a class in my ilayer as well and just spaced on it. Using the code you show below (same code, same Goodwin <s> ) it was just a matter of hooking it to the param in the DBCX and voila.

For non-VFE people - the framework resolves dynamic parameters before they hit the backend, so when I pass in a param that is a comma separated string 'Ohio','Michigan','Texas' the select statement SQL sees is

SELECT * from table where cfield in ('Ohio','Michigan','Texas')

Works like a charm.

I couldn't figure out how to declare

declare @param as varchar(100)
set @param = 'Ohio','Michigan','Texas'
I didn't know any other quotes that tsql would eat such as

[ 'Ohio','Michigan','Texas' ] or
" 'Ohio','Michigan','Texas' "

so I would get the string I wanted in

SELECT * from table where cfield in (@param)

(not sure I explained that very clearly in my question )


( I'm still going to check out all that great stuff Kevin and Sergey did as well, of course, as I am sure there is a lot to be learned there. Can never have too many tools in the box )

Thanks again to everyone who helped.

>Hey Charles:
>
>>In VFE I have the ability to using dynamic view parameters in remote views. Basically the framework will build SQL statements on the fly depending on the params passed with a great amount of control at the DBCX level for how the comparison will be done. I was looking for a TSQL syntax trick in the WHERE that would give me the equivalent to the inline function in VFP with INLIST where no other cursor is required.
>
>On the VFP side, I think you can create a view parameter behavior class and do something like the following in the GetSqlExpression() method - this code actual came from our friend Dan Goodwin...
>
>
>
>
>LPARAMETERS 	tlVFPSQL AS Boolean
>LOCAL lcvalue, lcreturn
>
>lcvalue=this.value
>lcreturn=""
>
>IF !EMPTY(lcvalue)
>	lcfield=ALLTRIM(this.oproperties.mcompareto)
>	IF !EMPTY(lcfield)
>		lcreturn=lcfield+" in ("+lcvalue+")"
>	endif	
>ENDIF
>
>RETURN lcreturn
>
>
>
>If you are working with Jeff, he should have this and related code in his i-layer. Check out iMover_dynamicvp of ivpMover.vcx which Dan helped me with while I was working at Blencowe. This is part of the code where we put a mover in a view parameter container to allow users to select multiple regions to select records with. The mover populates This.Value referenced above with a comma separated list.


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform