ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nilesh Bhattad" <nil...@outlinesys.com>
Subject Dynamic insert stmt
Date Thu, 27 Jan 2005 21:32:27 GMT
Hi there,
 
I have the below <insert/> statement defined in a sqlmap. If
'BlackListed' is not passed thro the HashMap, and rest of the fields are
passed in, one comma is inserted before 'isMarried' column and it
becomes an invalid sql stmt. I tried surrounding <isNotEmpty/> with
<dynamic/> tag, but that didn't help. (not sure if <dynamic/> can be
used within in insert stmt or not)
 
<insert id="insert" parameterClass="java.util.HashMap">
          insert into Consultant(
    <isNotEmpty property="BlackListed">BlackListed</isNotEmpty>
          <isNotEmpty property="isMarried"
prepend=",">isMarried</isNotEmpty>
          <isNotEmpty property="ActiveInactive"
prepend=",">ActiveInactive</isNotEmpty>
          <isNotEmpty property="HomeTelephone"
prepend=",">HomeTelephone</isNotEmpty>
          <isNotEmpty property="OfficeTelephone"
prepend=",">OfficeTelephone</isNotEmpty>
          <isNotEmpty property="OfficeTelExt"
prepend=",">OfficeTelExt</isNotEmpty>
          ) values (
    <isNotEmpty property="BlackListed">#BlackListed#</isNotEmpty>
          <isNotEmpty property="isMarried"
prepend=",">#isMarried#</isNotEmpty>
          <isNotEmpty property="ActiveInactive"
prepend=",">#ActiveInactive#</isNotEmpty>
          <isNotEmpty property="HomeTelephone"
prepend=",">#HomeTelephone#</isNotEmpty>
          <isNotEmpty property="OfficeTelephone"
prepend=",">#OfficeTelephone#</isNotEmpty>
          <isNotEmpty property="OfficeTelExt"
prepend=",">#OfficeTelExt#</isNotEmpty>
          )
          <selectKey resultClass="int" keyProperty="id">SELECT
@@IDENTITY as last_insert_id</selectKey>
     </insert>
 
Would someone please help me out to find what I'm doing wrong?
 
Thanks
Nilesh

Mime
View raw message