Advertisement
Benlahbib_Abdessamad

Untitled

May 27th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. Declare
  2. Cursor budget_cursor is (select * from budget where NOM_OPERATION='Courses') ;
  3. ligne budget_cursor % Rowtype;
  4.  
  5. Begin
  6. open budget_cursor;
  7.  
  8. loop
  9. Fetch budget_cursor into ligne;
  10. exit when budget_cursor%NotFound ;
  11. INSERT INTO Courses VALUES (ligne.num_operation,ligne.nom_operation,ligne.categorie,ligne.date_operation,ligne.montant) ;
  12. end loop;
  13. close budget_cursor;
  14.  
  15. END;
  16. /
  17.  
  18.  
  19. -----------------------------------------
  20.  
  21. DECLARE
  22. max_operation integer;
  23. new_solde integer;
  24. Begin
  25. select max(num_operation)+1 into max_operation from budget;
  26. select solde-500 into new_solde from budget where num_operation=(select max(num_operation)
  27. from budget);
  28. INSERT INTO BUDGET VALUES(max_operation,'Courses','Ddebit','14/01/2002',500,new_solde);
  29.  
  30. End;
  31. /
  32.  
  33.  
  34. ---------------------------------------------
  35.  
  36.  
  37. truncate table BUDGET_EURO;
  38.  
  39. Declare
  40. Cursor budget_ecursor is (select * from budget where DATE_OPERATION >'01/01/2002') ;
  41. ligne budget_ecursor % Rowtype;
  42.  
  43. Begin
  44. open budget_ecursor;
  45.  
  46. loop
  47. Fetch budget_ecursor into ligne;
  48. exit when budget_ecursor%NotFound ;
  49. INSERT INTO BUDGET_EURO VALUES (ligne.num_operation,ligne.nom_operation,ligne.categorie,ligne.date_operation,ligne.montant/11) ;
  50. end loop;
  51. close budget_ecursor;
  52.  
  53. END;
  54. /
  55.  
  56.  
  57.  
  58. ---------------------------------------------
  59.  
  60.  
  61. truncate table budget_seuil;
  62.  
  63. Accept x number Prompt " Entrez le seuil : "
  64. Declare
  65. Cursor budget_eSeuil(s number) is (select Num_operation,Date_operation,montant from budget where montant > s) ;
  66. ligne budget_eSeuil % Rowtype;
  67. seuil number;
  68. Begin
  69. seuil:=&x;
  70. open budget_eSeuil(seuil);
  71. loop
  72. Fetch budget_eSeuil into ligne;
  73. exit when budget_eSeuil%NotFound ;
  74. INSERT INTO BUDGET_SEUIL VALUES (ligne.num_operation,ligne.date_operation,ligne.montant) ;
  75. end loop;
  76. close budget_eSeuil;
  77.  
  78. END;
  79. /
  80.  
  81.  
  82. ------------------------------------------
  83.  
  84. truncate table budget_seuil;
  85. Accept x number Prompt " Entrez le seuil : "
  86. Declare
  87. Begin
  88. for ligne in (select Num_operation,Date_operation,montant from budget where montant > &x)
  89. loop
  90. INSERT INTO BUDGET_SEUIL VALUES (ligne.num_operation,ligne.date_operation,ligne.montant) ;
  91. end loop;
  92. END;
  93. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement