Subject | sql update |
---|---|
Author | Henrik Sitter |
Post date | 2004-02-06T20:20:14Z |
Hi, in a stored procedure I say something like this:
update aTable
set col1 = :inVal1, col2 = :inVal2, col3 = :inVal3
where col4 = '...';
inVal1, inVal2, inVal3 and inVal4 are input parameters, and the thing is
that I just want to update the columns where the input parameters are
not null. So if inVal1 is null and the other input parameters are not, I
want to update col2 and col3 but not col1.
Is there a clever way to do this, using some sort of if/case...
Thx,
Henrik
update aTable
set col1 = :inVal1, col2 = :inVal2, col3 = :inVal3
where col4 = '...';
inVal1, inVal2, inVal3 and inVal4 are input parameters, and the thing is
that I just want to update the columns where the input parameters are
not null. So if inVal1 is null and the other input parameters are not, I
want to update col2 and col3 but not col1.
Is there a clever way to do this, using some sort of if/case...
Thx,
Henrik