BEFORE DELETE OR INSERT OR UPDATE ON customers FOR EACH ROW WHEN (NEW.ID > 0) DECLARE sal_diff number; BEGIN sal_diff := :NEW.salary - :OLD.salary; dbms_output.put_line('Old salary: ' || :OLD.salary); dbms_output.put_line('New salary: ' || :NEW.salary); dbms_output.put_line('Salary difference: ' || sal_diff); END; / Trigger Created b)Perform the DMl Operation /*Insert Values to the table using Insert Command*/ Output: Old Salary: New salary: Salary Difference: /*Update using update statement*/ Output: Old Salary: New salary: Salary Difference: 8) Recursive Function DECLARE num number; factorial number;
FUNCTION calculateFact(x number)
RETURN number IS f number; BEGIN IF x = 0 THEN f := 1; ELSE f := x * calculateFact(x-1); END IF; RETURN f; END;
BEGIN num:= 6; factorial := calculateFact(num); DBMS_OUTPUT.PUT_LINE(' Factorial '|| num || ' is ' || factorial); END;