Created
November 10, 2014 14:13
-
-
Save polc/e648b61401f76d205336 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET SERVEROUTPUT ON | |
VARIABLE dept_id NUMBER := 0 | |
DECLARE | |
max_deptno NUMBER(11); | |
dept_name departments.department_name%TYPE := 'Education'; | |
BEGIN | |
DBMS_OUTPUT.PUT_LINE('Max dep: ' || :dept_id); | |
SELECT MAX(department_id) | |
INTO max_deptno | |
FROM departments; | |
DBMS_OUTPUT.PUT_LINE('Max dep: ' || max_deptno); | |
:dept_id := max_deptno + 10; | |
DBMS_OUTPUT.PUT_LINE('Max dep: ' || :dept_id); | |
INSERT INTO departments (department_id, department_name) | |
VALUES(:dept_id, dept_name); | |
DBMS_OUTPUT.PUT_LINE('Affected lines: ' || SQL%ROWCOUNT); | |
END; | |
/ | |
SELECT * | |
FROM departments | |
WHERE department_id = :dept_id; | |
/ | |
BEGIN | |
UPDATE departments | |
SET location_id = 3000 | |
WHERE department_id = :dept_id; | |
END; | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment