Proceduri Stocate
Proceduri Stocate
https://www.techonthenet.com/oracle/procedures.php
https://www.mkyong.com/oracle/oracle-stored-procedures-hello-world-examples/
http://psoug.org/reference/procedures.html
https://www.mkyong.com/oracle/oracle-stored-procedure-cursor-example/
https://docs.oracle.com/cd/B28359_01/appdev.111/b28844/procedures_plsql.htm#TDPNG60000
EXERCITIU 1: primeste ca param id angajat si creste salariul ang resp cu un al doilea param:
pEmpID employees.employee_id%type,
pValModificare int
IS
BEGIN
DBMS_OUTPUT.PUT_LINE(sql%rowcount);
END;
*aici ca sa testez procedura
pDepId departments.department_id%type,
IS
BEGIN
END;
Apelam asa:
declare
cout SYS_REFCURSOR;
rand employees%rowtype;
begin
Angajati_FCTDE_Departament(30, cout);
loop
end loop;
end;
EXERCITIU 3: PROCEDURA PRIN CARE SA ADAUGAM IN BD IN TABELA ANGAJAT. DACA ANG SE FACE
UPDATE LA SAL SAU LA DEP, DACA NU EXISTA SE ADAUGA. CU DML MERGE
https://www.oracletutorial.com/oracle-basics/oracle-merge/
https://livesql.oracle.com/apex/livesql/file/content_PC76LRDFFAVI6P6LMCWJLBOP2.html
declare
begin
pnume as nume,
pprenume as prenume,
psal as sal,
on (a.Employee_id = p.EmpId)
DBMS_OUTPUT.put_line(sql%rowcount);
commit; --!!!
end;
Ex 4:
Intai adaug un ang cu sal=30000
empl IN employees.employee_id%TYPE,
t1 IN NUMBER
) IS
tax NUMBER;
sal NUMBER;
BEGIN
END IF;
SELECT
salary
INTO sal
FROM
employees
WHERE
employee_id = empl;
EXCEPTION
END calc_tax;
SET SERVEROUTPUT ON
BEGIN
calc_tax(100, 20);
END;
empl IN employees.employee_id%TYPE,
t1 IN NUMBER,
r1 OUT NUMBER
) IS
-- tax NUMBER;
sal NUMBER;
BEGIN
END IF;
SELECT
salary
INTO sal
FROM
employees
WHERE
employee_id = empl;
R1 := sal * t1 / 100;
EXCEPTION
END calc_tax_out;
SET SERVEROUTPUT ON
DECLARE
r NUMBER;
BEGIN
r := 0;
END;
1- Crear un procedimiento llamado visualizar que visualice el nombre y salario de todos los
empleados.
set serveroutput on
declare
x number;
begin
visualizar(90,x);
DBMS_OUTPUT.put_line(x);
end;