Check out "Dynamic Mapped Statements" in the documentation on page 49, specifically the isNotNull. Here is the example it lists:

<select id="dynamicGetAccountList"
                            resultMap="account-result" >
    select * from ACCOUNT
    <dynamic prepend="WHERE">
      <isNotNull prepend="AND" property="firstName"
        open=”(“ close=”)”>
        ACC_FIRST_NAME = #firstName#
        <isNotNull prepend="OR" property="lastName">
          ACC_LAST_NAME = #lastName#
        </isNotNull>
      </isNotNull>
      <isNotNull prepend="AND" property="emailAddress">
        ACC_EMAIL like #emailAddress#
      </isNotNull>
      <isGreaterThan prepend="AND" property="id" compareValue="0">
        ACC_ID = #id#
      </isGreaterThan>
    </dynamic>
    order by ACC_LAST_NAME
  </select>



On May 3, 2007, at 7:01 PM, Koka Kiknadze wrote:

Check the <isNull> element in users quide. Think that's exactly what you need,



On 5/4/07, Andrew B <[EMAIL PROTECTED]> wrote:
Hello,

I am using iBATIS 2.3.0. I want to map a query for a report, that will have some optional selection criteria. If I map the query with these criteria as parameters, and then send null values for ones the user has not selected, will SQL Map leave them out of the query? Or, if not, is there a way to do this? (I want to avoid using a stored procedure if possible).

Thanks,

Andrew B

Ahhh...imagining that irresistible "new car" smell?
Check out new cars at Yahoo! Autos.


Reply via email to