ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <larry.mead...@gmail.com>
Subject Re: Update only when value is not null
Date Thu, 10 Mar 2005 04:45:32 GMT
Dude.

At least skim the docs before posting. :-)

Larry


On Mon, 7 Mar 2005 17:12:40 +0200, Meindert
<meindert@pastelebusiness.com> wrote:
>  
>  
> 
> Update only when value is not null (or "" or 0) 
> 
>   
> 
> Hi there, 
> 
>   
> 
> I try to make iBatis do a update only if the propertie in my object contains
> data 
> 
> How do I do this? 
> 
>   
> 
> Example, 
> 
> I'm receiving a XML file that may contain some column values that need to
> get updated: 
> 
> <employees xmlns='http://openuri.org/empschema' company='1'> 
> 
>   <employee> 
> 
>      <Code>852</Code> 
> 
>      <Surname>Dalton</Surname> 
> 
>      <EmplName>Claire</EmplName> 
> 
>   </employee> 
> 
> </employees> 
> 
>   
> 
> I parse this into an employee object and get this through to my update
> statement; 
> 
> <update id="updateEmployeeDirect" parameterClass="xmlemployee"> 
> 
>    UPDATE EmplMain SET Surname = #surname#, EmplName = #emplName#, Nickname
> = #nickname#, 
> 
>          …… 
> 
>  ucEMPassword = #ucEMPassword# 
> 
>       WHERE Code = #code# 
> 
>   </update> 
> 
>   
> 
> This will not work because it is attempting to store null values, and even
> if it worked it would override my data! 
> 
>   
> 
> So I would like to do something like SET Surname = IIF(#surname# is null,
> Surname, #surname#) 
> 
>   
> 
> Can this be done? 
> 
>   
> 
> Meindert Hoving 
> 
>   
>  
> 
> --
>  No virus found in this outgoing message.
>  Checked by AVG Anti-Virus.
>  Version: 7.0.308 / Virus Database: 266.6.2 - Release Date: 3/4/2005
>

Mime
View raw message