PL/SQL Triggers A trigger is a PL/SQL block which will run automatically whenever an event occurs. PL/SQL block may be associated with a table, a view or to a database. A trigger is a procedure that is triggered automatically when on...
PL/SQL If-Then-Else Statement Oracle PL/SQL allow the following statements: if, if else, if elsif. if – then If a = 5 Then ... End If; if – then – else If b = 10 Then ... Else ... End If; if...
PL/SQL For Loop Example 1: DECLARE x number:=0; BEGIN FOR i IN 1 .. 5 LOOP x:= i; DBMS_OUTPUT.PUT_LINE (' x= ' || x); END LOOP; END; Example 2: BEGIN FOR i IN 1 .. 5 LOOP IF i NOT IN...
PL/SQL While Loop The Loop statement WHILE-LOOP run so long as the condition is true. Syntax: WHILE condition LOOP sql_statements LOOP END; Example: DECLARE x NUMBER:=0; BEGIN WHILE x < 5 LOOP x:= x + 1; DBMS_OUTPUT.PUT_LINE (' x= ' ||...
PL/SQL Case Statement PL/SQL Case Statement – This instruction can be used in SQL queries. PL/SQL Simple CASE Statement, CASE – WHEN Example: DECLARE v_val VARCHAR2(2); BEGIN v_val := 'D'; CASE v_val WHEN 'A' THEN DBMS_OUTPUT.PUT_LINE('1'); WHEN 'B' THEN DBMS_OUTPUT.PUT_LINE('2'); WHEN...