Title: the following case statement:
v_sal number: = 2000;
when v_sal <1500 then
v_tax: = v_sal * 0.03;
when v_sal <2500 then
v_tax: = v_sal * 0.04;
when v_sal <3500 then
v_tax: = v_sal * 0.05;
when v_sal <8000 then
v_tax: = v_sal * 0.08;
v_tax: = v_sal * 0.1;
Execution is completed, the value of the variable v_tax how much?
Under the first test results?
cmd database on the sqlplus connection, perform set serveroutput on; open the console output displays,
And then copy the above statement, in the end; before the a: dbms_output.put_line (v_tax);
Console output: 80
The correct answer is: 80
It can be seen: Oracle in the case ... when the block is different from Java in the case ... when, oracle once a match is found in the results will be returned directly.
If the case statement is not found eligible when statements and positions with no ELSE clause, then the error will oralce: ORA-06592: implementation of CASE statement CASE not found
case, there are two expressions:
1 simple Oracle case expressions, using the expression to determine the return value.
WHEN expression1 THEN result1
WHEN expression2 THEN result2
WHEN expressionN THEN resultN
2 search case expression, the use of conditions to determine the return value.
WHEN condition1 THEN result1
WHEN condistion2 THEN result
WHEN condistionN THEN resultN
Although the two forms in different places can be slightly different wording, such as PL / SQL fast, the words behind each statement has a semicolon when, in the other query is not required, but added an error!