Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. create or replace procedure IdentificaSospetti(Anno CONTRIBUENTI.Anno%TYPE , Professione PROFESSIONI.Professione%TYPE) is
  2.  
  3. cursor calcoloSpese is
  4. select CONTRIBUENTI.CF,RedditoIRPEF,Categoria,sum(Importo) as sommaImporto
  5. from CONTRIBUENTI,SPESE
  6. where CONTRIBUENTI.Professione=Professione and CONTRIBUENTI.Anno=Anno and SPESE.CF=CONTRIBUENTI.CF
  7. and to_char(SPESE.DATA,'yyyy')=to_char(Anno,'yyyy')
  8. group by CONTRIBUENTI.CF,RedditoIRPEF,Categoria
  9. order by 1;
  10.  
  11. coefficiente PROFESSIONI.Coefficiente%TYPE;
  12. flag boolean:=false;
  13. CF CONTRIBUENTI.CF%TYPE;
  14. Reddito CONTRIBUENTI.RedditoIRPEF%TYPE;
  15. Somma number:=0;
  16. moltiplicatore number:=0;
  17.  
  18. begin
  19.  
  20. Select Coefficiente into coefficiente
  21. From PROFESSIONI
  22. Where PROFESSIONI.Professione=Professione;
  23.  
  24. for tmp in calcoloSpese loop
  25. if(flag=false) then
  26. flag:=true;
  27. CF:=tmp.CF;
  28. Reddito:=tmp.RedditoIRPEF;
  29. end if;
  30.  
  31. if(CF!=tmp.CF) then
  32.  
  33. Somma:=Somma*coefficiente;
  34. if(Somma>Reddito*1.50) then
  35. DBMS_OUTPUT.PUT_LINE('Contribuente '||CF||' sospetto');
  36. end if;
  37. CF:=tmp.cf;
  38. Reddito:=tmp.RedditoIRPEF;
  39. Somma:=0;
  40. end if;
  41.  
  42. if(tmp.Categoria='Casa') then
  43. moltiplicatore:=0.05;
  44. elsif (tmp.Categoria='Vacanze')then
  45. moltiplicatore :=2;
  46. elsif (tmp.Categoria='Abbigliamento')then
  47. moltiplicatore :=1.5;
  48. else
  49. moltiplicatore :=1;
  50. end if;
  51. Somma:=Somma+(tmp.sommaImporto*moltiplicatore);
  52. end loop;
  53.  
  54. EXCEPTION
  55. when NO_DATA_FOUND then
  56. DBMS_OUTPUT.PUT_LINE('Professioen non presente');
  57.  
  58. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement