0% found this document useful (0 votes)
4 views1 page

PLSQL Tarea 2

The document contains a series of PL/SQL blocks that manage a department in a database. It includes inserting a new department named 'INFORMATICA', updating its location ID, and finally deleting the department. Each operation is followed by a commit and a message output indicating the result of the operation.

Uploaded by

brunofioriloar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

PLSQL Tarea 2

The document contains a series of PL/SQL blocks that manage a department in a database. It includes inserting a new department named 'INFORMATICA', updating its location ID, and finally deleting the department. Each operation is followed by a commit and a message output indicating the result of the operation.

Uploaded by

brunofioriloar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

DECLARE

nuevo_department_id departments.department_id%TYPE;
BEGIN
SELECT MAX(department_id) + 1
INTO nuevo_department_id
FROM departments;

INSERT INTO departments (department_id, department_name, manager_id,


location_id)
VALUES (nuevo_department_id, 'INFORMATICA', 100, 1000);
COMMIT;

DBMS_OUTPUT.PUT_LINE('Nuevo departamento insertado con department_id: ' ||


nuevo_department_id);
END;

DECLARE
department_id departments.department_id%TYPE;
BEGIN
SELECT department_id
INTO department_id
FROM departments
WHERE department_name = 'INFORMATICA';

UPDATE departments
SET location_id = 1000
WHERE department_id = department_id;

COMMIT;

DBMS_OUTPUT.PUT_LINE('El location_id del departamento ' || department_id || '


ha sido actualizado a 1700.');
END;

DECLARE
department_id departments.department_id%TYPE;
BEGIN
SELECT department_id
INTO department_id
FROM departments
WHERE department_name = 'INFORMATICA';

DELETE FROM departments


WHERE department_id = department_id;

COMMIT;

DBMS_OUTPUT.PUT_LINE('Departamento con ID ' || department_id || ' eliminado.');


END;

You might also like