Queries using IN keyword

I would like to use a TQuery with the SQL set as follows

Select <fields> from <tabname> where <field> in :paramter

Is this possible?

Ta,

Robert.
BlimboAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kretzschmarCommented:
hi blimbo,

No, not possible in this way (with a parameter)

you must build the sql-statement at runtime.

meikl
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
florisbCommented:
Hi,

the use of IN:

WHERE FieldName IN ('New York','Amsterdam')

or

WHERE <expression> IN <subquery>


greetings,
Floris.


0
BlimboAuthor Commented:
Thanks,

Building up the query at run-time won't be too much of a problem but it seems that this is a limitation in the  TQuery component.

Robert.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

kretzschmarCommented:
hi blimbo,

thats not a limitation by tquery
it is a limitation by sql
(you can't store a set in a parameter)

meikl
0
BlimboAuthor Commented:
Thanks meikl,

Just out of interest why can't you store a set in a parameter?

Robert.
0
kretzschmarCommented:
pu,
there i must guess
maybe because

1. it is no datatype defined for this
2. a set is dynamic
3. a set may have a pre-run (SubSelect)
4. a parameter must have a fixed value ->see 3.
5. the sql-parser don't rebuild the statement (SubSelect as parameter)

just a guess, don't know it exact

meikl


0
BlimboAuthor Commented:
Hi meikl,

thanks again,

Robert.
0
mchaggisCommented:
Build the SQL statement at runtime and assign it to the TQuery.
0
kretzschmarCommented:
hi mchaggis,
see my first comment
meikl
0
mchaggisCommented:
kretzschmar, well then looks like this fella should build the TQuery in code and be done with it :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.