Hi guys,
I have a doubt regarding the CASE statement. It might sound silly, but me being new to DB2, it is kind of a genuine doubt. Try helping me with this..
When we use a case statement (simple-case-statement-when-clause), in this -
the value of the expression prior to the first WHEN keyword is tested for equality with the value of each expression that follows the WHEN keyword. Right?
Then if the search condition is true, the THEN statement is executed. If the result is unknown or false, processing continues to the next search condition. If the result does not match any of the search conditions, and an ELSE clause is present, the statements in the ELSE clause are processed.
Now my doubt is, suppose the expression satisfies two conditions of the case statement, then will it execute the first one that satisfies? or will it execute all of them that do?
for eg.
A = 57;
B=0;
case when A <= 60 then B = 1
when A <= 80 then B = 2
else B = 3
end
In this case, B would first be set to 1. But then would it also reset to 2 after the case statement has been processed?
Thanks in advance! :)