You are on page 1of 3

*set serverouput on declare a number(3); b varchar(20); x employees.

employee_id%type; begin select * into nou from employees where employee_id = 137; dbms_output.put_line (nou.salary || ' ' || nou.department_id); end;*/ rollback; /*set serveroutput on declare type info is record(cod number(3), nume varchar2(20), sal employees.salary%type, dep number (3)); aux info; begin delete from employees where employee_id=180 returning employee_id, last_name, salary, department_id into aux; dbms_output.put_line(aux.cod); end;*/ /* create or replace type info is object(cod number(3), nume varchar2(20), sal type, dep number (3)); set serveroutput on; declare aux info; begin delete from employees where employee_id=180 returning employee_id, last_name, salary, department_id into aux; dbms_output.put_line(aux.cod); end; */ /*set serveroutput on declare d departments%rowtype; begin select * into d from departments where department_id=&&cod; d.department_name:='sala308'; d.manager_id:=100; update departments set row=d where department_id=&cod; end; */ /*create table rinsert(cod number(2), text varchar(20)); set serveroutput on declare type linie is record (c1 number(2), c2 varchar2(20)); vlinie linie;

begin vlinie.c1:=5; vlinie.c2:='linie'; insert into rinsert values vlinie; insert into rinsert values(3, 'trei'); end; */ --se citeste de la tastatura un cod de dep se cere cel mai mic si cel mai mare s alariu-/*set serveroutput on declare type x is record(salmin number(8,2),salmax number(8,2)); y x; begin select min(salary), max(salary) into y from employees where department_id= & cod; dbms_output.put_line(y.salmin || ' ' ||y.salmax); end; */ /*set serveroutput on declare type tabind is table of number(4) index by pls_integer; v tabind; begin for i in 1..20 loop v (v.count+1):=i*i; end loop; for i in 1..v.count loop dbms_output.put_line(v(i)); end loop; end; */ /*set serveroutput on declare type tabind is table of number(4) index by pls_integer; v tabind; begin v.delete(7); indice:= v first; for i in 1..v.count loop dbms_output.put_line(v(indice)); indice:=v.next(indice); end loop; end; */ create table aux as select * from employees; create or replace type lista is varray(100) of number(6); alter table aux add colegi lista;

declare v lista:=lista(); begin for dep in (select distinct department_id from employees where department_id is not null) loop select employee_id bulk collect into v from employees where department_id=dep.department_id; update aux set colegi=v where department_id=dep.department_id; end loop; end;

You might also like