GOTO Statements
GOTO Statements
The GOTO statement lets you branch to a label unconditionally. The label, an undeclared identifier enclosed by double angle brackets, must precede an executable statement or a PL/SQL block. When executed, the GOTO statement transfers control to the labeled statement or block, as the following example shows:
IF rating > 90 THEN
GOTO calc_raise; -- branch to label
END IF;
...
<
IF job_title = 'SALESMAN' THEN -- control resumes here
amount := commission * 0.25;
ELSE
amount := salary * 0.10;
END IF;
SQL statements in PL/SQL
PL/SQL fully supports all SQL data manipulation statements (except EXPLAIN PLAN), transaction control statements, functions, pseudocolumns, and operators. PL/SQL also supports dynamic SQL, which enables you to execute SQL data definition, data control, and session control statements dynamically.
The following code block shows how to run DML statements in PL/SQL. Basically they look similar to the SQL. Note that the SELECT statement retrieves the single-row value and store into a variable using INTO clause.
DECLARE emp_sal employee.sal%TYPE;BEGIN
INSERT INTO employee VALUES (1, 'Ann Theja', 10000); UPDATE employee SET sal = sal + 5000 WHERE emp_id = 1;
SELECT sal INTO emp_sal FROM employee WHERE emp_id = 6;
DBMS_OUTPUT.PUT_LINE('Salary increased to ' emp_sal);
DELETE FROM employee WHERE emp_id = 1; COMMIT;END;

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home