razvanth21

Untitled

Nov 20th, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. set serveroutput on size 20000 word_wrapped;
  2.  
  3. create or replace procedure rez(CodC in number, Nume in varchar2, CNP in number, Adresa in varchar2, Pret in number)
  4. as
  5. begin
  6. insert into pasager values (CodC, Nume, CNP, Adresa, Pret);
  7. update curse set nrlib =
  8. case when (nrlib - 1) > 0
  9. then
  10. nrlib - 1
  11. end;
  12. end;
  13. /
  14.  
  15. declare
  16. idx number;
  17. totalSum number;
  18.  
  19. procedure afis(CodC in number) as
  20.  
  21. cursor c_afis is select c.*, t.nume from curse c join tehnic t on c.codp = t.cod where c.codc = CodC;
  22. r c_afis%rowtype;
  23.  
  24. cursor c_pasageri is select * from pasager p where p.codc = CodC;
  25. r2 c_pasageri%rowtype;
  26.  
  27. begin
  28. open c_afis;
  29. fetch c_afis into r;
  30.  
  31. if c_afis%notfound
  32. then
  33. dbms_output.put_line('Nu a putut fi gasita acea cursa.');
  34. else
  35. dbms_output.put_line('Cursa: ' || r.codc || ', Pilot: ' || r.nume || ', Nr. loc: ' || r.nrloc || ', Nr. Locuri Libere: ' || r.nrlib);
  36. dbms_output.put_line('Decolare: ' || r.oras_dec || ', Ora: ' || r.ora_dec || ', Aterizare: ' || r.oras_ater || ', Ora: ' || r.ora_ater);
  37. end if;
  38. close c_afis;
  39.  
  40. open c_pasageri;
  41. idx := 0;
  42. totalSum := 0;
  43.  
  44. loop
  45. fetch c_pasageri into r2;
  46. exit when c_pasageri%notfound;
  47.  
  48. dbms_output.put_line('Nr. Crt: ' || idx || ', CNP: ' || r2.cnp || ', Nume: ' || r2.nume || ', Adresa: ' || r2.adresa || ', Pret: ' || r2.pret);
  49.  
  50. idx := idx + 1;
  51. totalSum := totalSum + r2.pret;
  52. end loop;
  53.  
  54. dbms_output.put_line('Suma: ' || totalSum);
  55. close c_pasageri;
  56. end;
  57. /
  58.  
  59. begin
  60. afis(5);
  61. end;
  62. /
Add Comment
Please, Sign In to add comment