Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ACCEPT Etu PROMPT 'Entrez votre numéro étudiant: '
- ACCEPT Liv PROMPT 'Entrez votre numero de livre : '
- ACCEPT durrPret PROMPT 'Entrez votre durée de pret : '
- DECLARE
- mon_exception EXCEPTION;
- compteurEmprunt NUMBER(2) := 0;
- CURSOR mesLivres IS
- SELECT * FROM Livre
- WHERE numero = &Liv;
- monLivre Livre%ROWTYPE;
- CURSOR mesEtudiants IS
- SELECT * FROM Etudiant
- WHERE numero = &Etu;
- monEtudiant Etudiant%ROWTYPE;
- BEGIN
- SELECT COUNT(*) INTO compteurEmprunt
- FROM Emprunt;
- compteurEmprunt:= compteurEmprunt+1;
- OPEN mesLivres;
- LOOP
- FETCH mesLivres INTO monLivre;
- EXIT WHEN mesLivres%NOTFOUND;
- END LOOP;
- CLOSE mesLivres;
- OPEN mesEtudiants;
- LOOP
- FETCH mesEtudiants INTO monEtudiant;
- EXIT WHEN mesEtudiants%NOTFOUND;
- END LOOP;
- CLOSE mesEtudiants;
- if (monLivre.disponible =0) THEN
- RAISE mon_exception;
- else
- INSERT INTO Emprunt
- VALUES (compteurEmprunt,&Etu,&Liv,&durrPret,sysdate);
- UPDATE Livre
- SET disponible =0
- WHERE numero = &Liv;
- end if;
- EXCEPTION
- WHEN mon_exception THEN
- dbms_output.put_line('Livre deja emprunte !');
- WHEN no_data_found THEN
- dbms_output.put_line('No data found');
- WHEN others THEN
- dbms_output.put_line('ERREUR');
- END;
- /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement