You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Jorge DeCastro <jo...@flightcentre.co.uk> on 2006/01/19 14:15:47 UTC

SQL 'IN' clause

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.


Re: SQL 'IN' clause

Posted by Jorge DeCastro <jo...@flightcentre.co.uk>.
Right you are, thanks!

j.


Re: SQL 'IN' clause

Posted by Larry Meadors <lm...@apache.org>.
Look at the iterate tags.

Larry


On 1/19/06, Jorge DeCastro <jo...@flightcentre.co.uk> 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.
>
>