ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Meindert" <meind...@pastelebusiness.com>
Subject Update only when value is not null
Date Mon, 07 Mar 2005 15:12:40 GMT
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?

 

HYPERLINK "mailto:meindert@pastelebusiness.com"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