Advertisement
clevernessisamyth

PL/SQL TD5 EX1

Aug 20th, 2020 (edited)
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.57 KB | None | 0 0
  1. DECLARE
  2.   CURSOR quant IS
  3.   (
  4.     SELECT QUANTITE
  5.     FROM Commande
  6.     WHERE QUANTITE IS NOT NULL;
  7.   )
  8.   quant_temp NUMBER:=0;
  9.   quant_eval NUMBER:=0;
  10.   quantite NUMBER;
  11.   cpt NUMBER:=0;
  12. BEGIN
  13.   OPEN quant;
  14.   FETCH quant INTO quant_temp;
  15.   LOOP
  16.     FETCH quant INTO quantite
  17.     EXIT WHEN quant%NOTFOUND;
  18.     quant_val := quant_val + QUANTITE - quant_temp;
  19.     quant_temp := QUANTITE;
  20.     cpt := cpt + 1;
  21.   END LOOP;
  22.   DBMS_OUTPUT.put_line("Totale: "||quant_val/cpt);
  23. EXCEPTION
  24.   WHEN DATA_NO_FOUND THEN
  25.     DBMS_OUTPUT.put_line("Commande is empty!");
  26. END;
  27. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement