Advertisement
mmouhib

Untitled

Apr 4th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. --ex1
  2. drop table resultat;
  3. create table resultat (
  4. IDART number(20),
  5. DESART varchar(30),
  6. APU number(30),
  7. NPU number(30)
  8. );
  9. accept idarticle prompt 'Donner lid article : '
  10. declare
  11. CURSOR arts is select idart, desart, pu from article where qtestk <= qtemin;
  12. ida number;
  13. da number;
  14. qa number;
  15. pa number;
  16. FUNCTION cal_approv(code_art article.idart%type)
  17. RETURN number IS qte_app number;
  18. qtot number;
  19. qtestk number;
  20. qtemin number;
  21. begin
  22. select sum(QTECOM) into qtot from lig_com where idart=code_art;
  23. select qtestk into qtestk from article where idart=code_art;
  24. select qtemin into qtemin from article where idart=code_art;
  25. if (qtot/qtestk)>(2*qtemin) then
  26. qte_app := (qtot-qtestk)*1.5;
  27. else
  28. qte_app := qtot*1.2;
  29. end if;
  30. return qte_app;
  31. end;
  32.  
  33.  
  34. begin
  35.  
  36.  
  37.  
  38. for art in arts loop
  39. qa := cal_approv(art.idart);
  40. pa := art.pu*cal_approv(art.idart);
  41. exit when(arts%notfound);
  42. insert into resultat values
  43.  
  44. (art.idart,art.desart, qa,pa);
  45. end loop;
  46. end;
  47. /
  48.  
  49. select * from resultat;
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. --ex2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement