Labeled CASE Statements
0Labeled CASE Statements:
- A CASE statement can optionally be labelled, like a PL/SQL block.
- If a CASE statement is labelled, then the label can also appear after the END CASE clause.
SQL>DECLARE
v_TestVar NUMBER:=10;
BEGIN
<<Mycase>>
CASE v_TestVar
WHEN 10 THEN
DBMS_OUTPUT.PUT_LINK(‘ACCOUNTING’);
WHEN 20 THEN
DBMS_OUTPUT.PUT_LINK(‘RESEARCH’);
WHEN 30 THEN
DBMS_OUTPUT.PUT_LINK(‘SALES’);
WHEN 40 THEN
DBMS_OUTPUT.PUT_LINK(‘OPERATIONS’);
END CASE Mycase;
END;
v_TestVar NUMBER:=10;
BEGIN
<<Mycase>>
CASE v_TestVar
WHEN 10 THEN
DBMS_OUTPUT.PUT_LINK(‘ACCOUNTING’);
WHEN 20 THEN
DBMS_OUTPUT.PUT_LINK(‘RESEARCH’);
WHEN 30 THEN
DBMS_OUTPUT.PUT_LINK(‘SALES’);
WHEN 40 THEN
DBMS_OUTPUT.PUT_LINK(‘OPERATIONS’);
END CASE Mycase;
END;
0 comments: