• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 121
  • Last Modified:

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.
0
Blimbo
Asked:
Blimbo
  • 4
  • 3
  • 2
  • +1
1 Solution
 
kretzschmarCommented:
hi blimbo,

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

you must build the sql-statement at runtime.

meikl
0
 
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now