SHARE
TWEET

BD lab 1

a guest Feb 24th, 2020 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 1.
  2. SET SERVEROUTPUT ON;
  3.  
  4. DECLARE
  5. nume VARCHAR2(30) := 'Acroitoritei';
  6. prenume nume%TYPE := 'Calin';
  7. grupa INT := 3141;
  8. data DATE := SYSDATE;
  9.  
  10. BEGIN
  11. DBMS_OUTPUT.PUT_LINE ('Hello world!');
  12. DBMS_OUTPUT.PUT_LINE (nume || ' ' || prenume || ' ' || grupa || ' ' || data);
  13.  
  14. END;
  15.  
  16. 2.
  17. SET SERVEROUTPUT ON;
  18.  
  19. DECLARE
  20. a REAL := 3;
  21. b REAL := 154;
  22. rez REAL:= a + b;
  23.  
  24. BEGIN
  25. DBMS_OUTPUT.PUT_LINE(rez);
  26.  
  27.  
  28. END;
  29.  
  30. 3.
  31. SET SERVEROUTPUT ON;
  32.  
  33. DECLARE
  34. v_nume Employees.last_name%TYPE;
  35.  
  36. BEGIN
  37. SELECT last_name INTO v_nume FROM employees WHERE employee_id = 100;
  38. DBMS_OUTPUT.PUT_LINE(v_nume);
  39.  
  40. END;
  41.  
  42. 4.
  43. SET SERVEROUTPUT ON;
  44.  
  45. DECLARE
  46. v_sal Employees.salary%TYPE;
  47.  
  48. BEGIN
  49. SELECT salary INTO v_sal FROM employees WHERE last_name LIKE 'Popp';
  50. DBMS_OUTPUT.PUT_LINE(v_sal);
  51.  
  52. END;
  53.  
  54. 5.
  55. SET SERVEROUTPUT ON;
  56.  
  57. DECLARE
  58. v_sal Employees.salary%TYPE;
  59.  
  60. BEGIN
  61. SELECT salary INTO v_sal FROM employees WHERE last_name LIKE 'Popp';
  62. DBMS_OUTPUT.PUT_LINE(v_sal);
  63.  
  64. v_sal := 666;
  65. UPDATE employees SET salary  = v_sal WHERE last_name = 'Popp';
  66. END;
  67.  
  68. 6.
  69. SET SERVEROUTPUT ON;
  70.  
  71. DECLARE
  72. nr_emp INT;
  73.  
  74. BEGIN
  75. SELECT COUNT(*) INTO nr_emp FROM employees WHERE department_id = 30;
  76. DBMS_OUTPUT.PUT_LINE(nr_emp);
  77.  
  78. END;
  79.  
  80. 7.
  81. --deps_calin
  82. SET SERVEROUTPUT ON;
  83.  
  84. DECLARE
  85. max_dept_id INT;
  86. dep_name VARCHAR(20) := 'Departament nou';
  87. man_id INT := 33;
  88. loc_id INT := 103;
  89.  
  90. BEGIN
  91. SELECT MAX(department_id) INTO max_dept_id FROM departments;
  92. DBMS_OUTPUT.PUT_LINE(max_dept_id);
  93. INSERT INTO deps_calin VALUES(max_dept_id + 1 , dep_name, man_id, loc_id);
  94.  
  95. END;
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