You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Meindert <me...@pastelebusiness.com> on 2005/03/07 16:12:40 UTC
Update only when value is not null
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
Re: Update only when value is not null
Posted by Larry Meadors <la...@gmail.com>.
Dude.
At least skim the docs before posting. :-)
Larry
On Mon, 7 Mar 2005 17:12:40 +0200, Meindert
<me...@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
>