SHARE
TWEET

Untitled

a guest Oct 20th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. set serveroutput on;
  3. declare
  4.     cursor c_angajati is
  5.         select d.dname, e.empno, e.ename, e.sal, e.hiredate
  6.             from emp e inner join dept d on e.deptno = d.deptno
  7.                 where e.hiredate like '%81'
  8.                 order by hiredate;
  9.     v_angajat c_angajati%rowtype;
  10. begin
  11.     open c_angajati;
  12.     loop
  13.         fetch c_angajati into v_angajat;
  14.         exit when c_angajati%notfound;
  15.         dbms_output.put_line(v_angajat.dname || ' ' || v_angajat.empno
  16.             || ' ' || v_angajat.ename || ' ' || v_angajat.sal || ' ' || v_angajat.hiredate);
  17.     end loop;
  18.     close c_angajati;
  19. end;
  20. */
  21.  
  22. /*
  23. set serveroutput on;
  24. declare
  25.     cursor c_angajati is
  26.         select d.dname, e.empno, e.ename, e.sal, e.comm
  27.             from emp e inner join dept d on d.deptno = e.deptno
  28.                 where lower(e.job) like lower('Manager');
  29.     angajat c_angajati%rowtype;
  30.     venit number := 0;
  31. begin
  32.     open c_angajati;
  33.     dbms_output.put_line(rpad('ECUSON', 10) || rpad('NUME', 20)
  34.         || rpad('DEPARTAMENT', 20) || lpad('VENIT', 10));
  35.     dbms_output.put_line(rpad('=', 10, '=') || rpad('=', 20, '=')
  36.         || rpad('=', 20, '=') || lpad('=', 10, '='));
  37.     loop
  38.         fetch c_angajati into angajat;
  39.         exit when c_angajati%NOTFOUND;
  40.         venit := round(angajat.sal + nvl(angajat.comm, 0));
  41.         dbms_output.put_line(rpad(angajat.empno, 10) || rpad(angajat.ename, 20)
  42.             || rpad(angajat.dname, 20) || lpad(venit, 10));
  43.         venit := 0;
  44.     end loop;
  45.     close c_angajati;
  46. end;
  47. */
  48. /*
  49. set serveroutput on;
  50. declare
  51.     cursor c_angajati is
  52.         select d.dname, e.empno, e.ename, e.sal, e.comm
  53.             from emp e inner join dept d on d.deptno = e.deptno
  54.                 where lower(e.job) like lower('Manager');
  55.     angajat c_angajati%rowtype;
  56.     venit number := 0;
  57. begin
  58.     dbms_output.put_line(rpad('ECUSON', 10) || rpad('NUME', 20)
  59.         || rpad('DEPARTAMENT', 20) || lpad('VENIT', 10));
  60.     dbms_output.put_line(rpad('=', 10, '=') || rpad('=', 20, '=')
  61.         || rpad('=', 20, '=') || lpad('=', 10, '='));
  62.     for angajat in c_angajati
  63.     loop
  64.         venit := round(angajat.sal + nvl(angajat.comm, 0));
  65.         dbms_output.put_line(rpad(angajat.empno, 10) || rpad(angajat.ename, 20)
  66.             || rpad(angajat.dname, 20) || lpad(venit, 10));
  67.         venit := 0;
  68.     end loop;
  69. end;
  70. */
  71. /*
  72. set serveroutput on;
  73. declare
  74.     venit number := 0;
  75. begin
  76.     dbms_output.put_line(rpad('ECUSON', 10) || rpad('NUME', 20)
  77.         || rpad('DEPARTAMENT', 20) || lpad('VENIT', 10));
  78.     dbms_output.put_line(rpad('=', 10, '=') || rpad('=', 20, '=')
  79.         || rpad('=', 20, '=') || lpad('=', 10, '='));
  80.     for angajat in (select d.dname, e.empno, e.ename, e.sal, e.comm
  81.             from emp e inner join dept d on d.deptno = e.deptno
  82.                 where lower(e.job) like lower('Manager'))
  83.     loop
  84.         venit := round(angajat.sal + nvl(angajat.comm, 0));
  85.         dbms_output.put_line(rpad(angajat.empno, 10) || rpad(angajat.ename, 20)
  86.             || rpad(angajat.dname, 20) || lpad(venit, 10));
  87.         venit := 0;
  88.     end loop;
  89. end;
  90. */
  91.  
  92. /*
  93. set serveroutput on;
  94. declare
  95.     cursor c_angajati is
  96.         select d.dname, e.empno, e.ename, e.sal, e.comm, e.hiredate
  97.             from emp e inner join dept d on d.deptno = e.deptno
  98.                 for update of comm;
  99.     angajat c_angajati%rowtype;
  100.     comisionNou number default 0;
  101. begin
  102.     open c_angajati;
  103.     loop
  104.         fetch c_angajati into angajat;
  105.         exit when c_angajati%notfound;
  106.         if add_months(angajat.hiredate, 240) < sysdate then
  107.             comisionNou := nvl (angajat.comm, 0) + round(0.1 * angajat.sal, 0);
  108.             update emp set comm = comisionNou where current of c_angajati;
  109.         end if;
  110.     end loop;
  111.     close c_angajati;
  112. end;
  113. */
  114.  
  115. /*
  116. set serveroutput on;
  117. BEGIN
  118.     FOR angajat IN (SELECT empno FROM emp WHERE comm IS NULL)
  119.     LOOP
  120.         DELETE FROM emp
  121.         WHERE empno = angajat.empno;
  122.     END LOOP;
  123. END;
  124. */
  125.  
  126. /*
  127. set serveroutput on;
  128. declare
  129.     type r_cursor is REF CURSOR;
  130.     c_emp r_cursor;
  131.     angajat emp%rowtype;
  132. begin
  133.     open c_emp for select * from emp;
  134.     loop
  135.         fetch c_emp into angajat;
  136.         exit when c_emp%notfound;
  137.         dbms_output.put_line(angajat.ename || ' ' || angajat.job
  138.             || ' ' || angajat.sal);
  139.     end loop;
  140.     close c_emp;
  141. end;
  142. */
  143. /*
  144. set serveroutput on;
  145. declare
  146.     type r_cursor is ref cursor;
  147.     type rec_ang is record(
  148.         nume emp.ename%type,
  149.         functie emp.job%type,
  150.         salariu emp.sal%type
  151.     );
  152.     c_ang r_cursor;
  153.     angajat rec_ang;
  154. begin
  155.     open c_ang for select ename, job, sal from emp;
  156.     loop
  157.         fetch c_ang into angajat;
  158.         exit when c_ang%notfound;
  159.         dbms_output.put_line(angajat.nume || ' ' || angajat.functie
  160.             || ' ' || angajat.salariu);
  161.     end loop;
  162.     close c_ang;
  163. end;
  164. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top