Help Center > > Developer Guide> Stored Procedures> Control Statements> Branch Statements

Branch Statements

Updated at: Mar 13, 2020 GMT+08:00

Syntax

Figure 1 shows the syntax diagram.

Figure 1 case_when::=

Figure 2 shows the syntax diagram for when_clause.

Figure 2 when_clause::=

Parameter description:

  • case_expression: specifies the variable or expression.
  • when_expression: specifies the constant or conditional expression.
  • statement: specifies the statement to execute.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
CREATE OR REPLACE PROCEDURE proc_case_branch(pi_result in integer, pi_return out integer)
AS 
    BEGIN 
        CASE pi_result 
            WHEN 1 THEN 
                pi_return := 111; 
            WHEN 2 THEN 
                pi_return := 222; 
            WHEN 3 THEN 
                pi_return := 333; 
            WHEN 6 THEN 
                pi_return := 444; 
            WHEN 7 THEN 
                pi_return := 555; 
            WHEN 8 THEN 
                pi_return := 666; 
            WHEN 9 THEN 
                pi_return := 777; 
            WHEN 10 THEN 
                pi_return := 888; 
            ELSE 
                pi_return := 999; 
        END CASE; 
        raise info 'pi_return : %',pi_return ; 
END; 
/

CALL proc_case_branch(3,0);

-- Delete the stored procedure:
DROP PROCEDURE proc_case_branch;

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel