Skip to content

1.5 PL SQL CASE WHEN AND VARIABLE

thuantt0101 edited this page Dec 9, 2019 · 1 revision

CASE WHEN AND VARIABLE

DECLARE 
V_A VARCHAR(20) ;
V_B VARCHAR(20);
BEGIN
    V_A:='1';
    CASE
    WHEN V_A = '1' THEN V_B:='MOT';
    WHEN V_A = '2' THEN V_B:='HAI';
    WHEN V_A = '3' THEN V_B:='BA';
    ELSE V_B:='';
  END CASE;
  
  DBMS_OUTPUT.PUT_LINE(V_B);
END;