Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. /*Zad 1*/
  2.  
  3. CREATE TABLE course(
  4. id_course NUMBER(10) PRIMARY KEY NOT NULL,
  5. name VARCHAR2(50),
  6. start_course DATE,
  7. end_course DATE,
  8. description VARCHAR2(100),
  9. price NUMBER (6,2)
  10. );
  11.  
  12. INSERT INTO course VALUES (1, 'Kurs 1', '1-OCT-18', '15-OCT-18', 'Opis 1', 10);
  13. INSERT INTO course VALUES (2, 'Kurs 2', '2-OCT-18', '15-OCT-18', 'Opis 2', 20);
  14. INSERT INTO course VALUES (3, 'Kurs 3', '3-OCT-18', '15-OCT-18', 'Opis 3', 30);
  15. INSERT INTO course VALUES (4, 'Kurs 4', '4-OCT-18', '15-OCT-18', 'Opis 4', 40);
  16. INSERT INTO course VALUES (5, 'Kurs 5', '5-OCT-18', '15-OCT-18', 'Opis 5', 50);
  17. INSERT INTO course VALUES (6, 'Kurs 6', '6-OCT-18', '15-OCT-18', 'Opis 6', 60);
  18. INSERT INTO course VALUES (7, 'Kurs 7', '7-OCT-18', '15-OCT-18', 'Opis 7', 70);
  19. INSERT INTO course VALUES (8, 'Kurs 8', '8-OCT-18', '15-OCT-18', 'Opis 8', 80);
  20. INSERT INTO course VALUES (9, 'Kurs 9', '9-OCT-18', '15-OCT-18', 'Opis 9', 90);
  21. INSERT INTO course VALUES (10, 'Kurs 10', '10-OCT-18', '15-OCT-18', 'Opis 10', 10);
  22.  
  23. SELECT * FROM course;
  24.  
  25.  
  26. SET SERVEROUTPUT ON;
  27.  
  28. DECLARE
  29. CURSOR desc_cur IS
  30. SELECT description
  31. FROM course;
  32.  
  33. TYPE course_desc IS TABLE OF course.description%TYPE
  34. INDEX BY BINARY_INTEGER;
  35.  
  36. tab1 course_desc;
  37. v_counter INTEGER := 0;
  38.  
  39. BEGIN
  40. FOR i IN desc_cur LOOP
  41. tab1(v_counter) := i.description;
  42. v_counter := v_counter + 1;
  43. END LOOP;
  44. DBMS_OUTPUT.PUT_LINE(tab1.count());
  45. DBMS_OUTPUT.PUT_LINE(tab1.first());
  46. DBMS_OUTPUT.PUT_LINE(tab1.last());
  47. END;
  48.  
  49. /*Zad 2*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement