ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From friendVU admin <maill...@friendvu.com>
Subject Re: Dynamic insert stmt
Date Thu, 27 Jan 2005 21:54:42 GMT
Try this syntax instead
INSERT
INTO load_email (
content, subject,
...
)
values (
#content:VARCHAR:NO_ENTRY#, #subject:VARCHAR:NO_ENTRY#,
...
)


Nilesh Bhattad wrote:

> 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