Control Flow in PL/SQL
Example 1
DECLARE
a NUMBER;
b NUMBER;
BEGIN
SELECT e,f INTO a,b FROM Table1 WHERE e>1;
IF b=1 THEN
INSERT INTO Table1 VALUES(b,a);
ELSE
INSERT INTO Table1 VALUES(b+10,a+10);
END IF;
END;
.
run;
Example 2
DECLARE
i NUMBER := 1;
BEGIN
LOOP
INSERT INTO Table1 VALUES(i,i);
i := i+1;
EXIT WHEN i>100;
END LOOP;
END;
.
run;
No comments:
Post a Comment