SQL 'IN' clause

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SQL 'IN' clause

Jorge DeCastro
Hi all,

I am using iBatis 2.1.6 with SQLServer and I can't make dynamic queries
work with SQL's 'IN' clause.
I have the string 'airlineFilter'.
If I pass a string containing one value (airlineFilter = "BA"), it works
fine. If I pass a comma-separated string of values (airlineFilter =
"BA,QF") to the dynamic IN clause, iBatis passes it as a single string and
hence I don't get the results I expect.


          <dynamic prepend="AND">
          <isNotNull property="airlineFilter">
          (PubAirRuleFlightRestriction.CarrierCode IN (#airlineFilter#))
            </isNotNull>
          </dynamic>

cheers
j.

Reply | Threaded
Open this post in threaded view
|

Re: SQL 'IN' clause

Larry Meadors-2
Look at the iterate tags.

Larry


On 1/19/06, Jorge DeCastro <[hidden email]> wrote:

> Hi all,
>
> I am using iBatis 2.1.6 with SQLServer and I can't make dynamic queries
> work with SQL's 'IN' clause.
> I have the string 'airlineFilter'.
> If I pass a string containing one value (airlineFilter = "BA"), it works
> fine. If I pass a comma-separated string of values (airlineFilter =
> "BA,QF") to the dynamic IN clause, iBatis passes it as a single string and
> hence I don't get the results I expect.
>
>
>           <dynamic prepend="AND">
>                 <isNotNull property="airlineFilter">
>                         (PubAirRuleFlightRestriction.CarrierCode IN (#airlineFilter#))
>             </isNotNull>
>           </dynamic>
>
> cheers
> j.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: SQL 'IN' clause

Jorge DeCastro
Right you are, thanks!

j.

Reply | Threaded
Open this post in threaded view
|

Re: SQL 'IN' clause

nupur17
This post has NOT been accepted by the mailing list yet.
I am having same problem. What is the resolution? no one mentioned :(