Thursday, February 16, 2012

column chechking while updating

If amc.amc2>0 then
UPDATE amc set AMC2= AMC2 + & val(txtamt.text) & where am1=1
else if amc.amc2<0 then
UPDATE amc set AMC2= & val(txtamt.text) & where am1=1
end if

Here I check the value of column with if condition statement. I need to check the column with out if condition statement.

What is my doubt is that how I can check value of amc2 column while updating.

eg: update amc set case when amc2>0 then AMC2= AMC2 + & val(txtamt.text)
like this

Is it possible with case-when -end?

If it is possible I can solve a big problem in my project.
Can you give me an example with this query?update amc
set amc2 = & val(txtamt.text) & + (CASE WHEN amc2 >= 0 THEN amc2 ELSE 0 END)
where am1=1;

No comments:

Post a Comment