Advertisement
Guest User

POUR ZED

a guest
Dec 19th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1.  
  2. ACCEPT Etu PROMPT 'Entrez votre numéro étudiant: '
  3. ACCEPT Liv PROMPT 'Entrez votre numero de livre : '
  4. ACCEPT durrPret PROMPT 'Entrez votre durée de pret : '
  5. DECLARE
  6. mon_exception EXCEPTION;
  7.  
  8. compteurEmprunt NUMBER(2) := 0;
  9.  
  10. CURSOR mesLivres IS
  11. SELECT * FROM Livre
  12. WHERE numero = &Liv;
  13.  
  14. monLivre Livre%ROWTYPE;
  15.  
  16. CURSOR mesEtudiants IS
  17. SELECT * FROM Etudiant
  18. WHERE numero = &Etu;
  19.  
  20. monEtudiant Etudiant%ROWTYPE;
  21. BEGIN
  22. SELECT COUNT(*) INTO compteurEmprunt
  23. FROM Emprunt;
  24.  
  25. compteurEmprunt:= compteurEmprunt+1;
  26.  
  27. OPEN mesLivres;
  28. LOOP
  29. FETCH mesLivres INTO monLivre;
  30. EXIT WHEN mesLivres%NOTFOUND;
  31. END LOOP;
  32. CLOSE mesLivres;
  33.  
  34. OPEN mesEtudiants;
  35. LOOP
  36. FETCH mesEtudiants INTO monEtudiant;
  37. EXIT WHEN mesEtudiants%NOTFOUND;
  38. END LOOP;
  39. CLOSE mesEtudiants;
  40.  
  41. if (monLivre.disponible =0) THEN
  42. RAISE mon_exception;
  43. else
  44.  
  45. INSERT INTO Emprunt
  46. VALUES (compteurEmprunt,&Etu,&Liv,&durrPret,sysdate);
  47.  
  48. UPDATE Livre
  49. SET disponible =0
  50. WHERE numero = &Liv;
  51.  
  52. end if;
  53.  
  54. EXCEPTION
  55. WHEN mon_exception THEN
  56. dbms_output.put_line('Livre deja emprunte !');
  57. WHEN no_data_found THEN
  58. dbms_output.put_line('No data found');
  59. WHEN others THEN
  60. dbms_output.put_line('ERREUR');
  61. END;
  62. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement