ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <rohini.gan...@wipro.com>
Subject Help required to write a query
Date Wed, 12 Apr 2006 04:49:22 GMT

Hi,



I am using the below code to retrieve user details from a table:




<select id="searchUser" parameterClass="searchCriteria"
resultClass="searchCriteria" resultMap="userMap2">

select * from USR_BASIC_INFO   

  <dynamic prepend="where">  

   <iterate property="userlist" conjunction="or"> USR_ID=#userlist[]#  

     and(

     <isParameterPresent>    

     <isEqual property="operator" compareValue="and">     

      <isNotNull prepend="and" property="username"
removeFirstPrepend="true"> USR_NAME=#username# </isNotNull>     

       <isNotNull prepend="and" property="phonenumber"
removeFirstPrepend="true"> PHONE_NUMBER=#phonenumber# </isNotNull>

      </isEqual> 

     </isParameterPresent> 

        

     <isParameterPresent>   

      <isEqual property="operator" compareValue="or">


        <isNotNull prepend="or" property="username"
removeFirstPrepend="true"> USR_NAME=#username# </isNotNull>

        <isNotNull prepend="or" property="phonenumber"
removeFirstPrepend="true"> PHONE_NUMBER=#phonenumber# </isNotNull>

      </isEqual>

     </isParameterPresent>     

         )

    </iterate>   

   </dynamic>

</select>



But during execution, I am getting the following error, i.e "and" is
appended twice:



select * from USR_BASIC_INFO               where          USR_ID=?
and(
USR_NAME=?                     and PHONE_NUMBER=?
)      or USR_ID=?       and(
and USR_NAME=?                 and PHONE_NUMBER=?
)      or USR_ID=?          and(
and USR_NAME=?                 and PHONE_NUMBER=?
)      or USR_ID=?       and(
and USR_NAME=?                 and PHONE_NUMBER=?
)   . 

Can you please tell how the query is to be written?



Regards,

Rohini






The information contained in this electronic message and any attachments to this message are
intended for the exclusive use of the addressee(s) and may contain proprietary, confidential
or privileged information. If you are not the intended recipient, you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately and destroy all copies
of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email
and any attachments for the presence of viruses. The company accepts no liability for any
damage caused by any virus transmitted by this email.

www.wipro.com
Mime
View raw message