SQL Statements in PL/SQL

Submitted by:Tim Kelly

Date added:01 December, 2011

Category:PL SQL

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.

Tags: sql statement

Code Snippet:

DECLARE
v_sal employee.sal%TYPE;

BEGIN

INSERT INTO employee VALUES (6, 'TOM LEE', 10000);
UPDATE employee SET sal = sal + 5000 WHERE empno = 6;
SELECT sal INTO v_sal FROM employee WHERE empno = 6;
DBMS_OUTPUT.PUT_LINE('Salary increased to ' || v_sal);
DELETE FROM employee WHERE empno = 6;

COMMIT;
END;

 
 

Comments