Commit 07547ce8 authored by Elias Leinenweber's avatar Elias Leinenweber
Browse files

last commit

parent c3f490dc
SET SERVEROUTPUT ON;
SET SERVEROUTPUT ON FORMAT WRAPPED;
CREATE OR REPLACE PACKAGE GestionCarte IS
PROCEDURE PizzasSansIng(nomIng ingredient.libelle%TYPE);
......@@ -16,7 +16,7 @@ CREATE OR REPLACE PACKAGE BODY GestionCarte IS
*/
PROCEDURE PizzasSansIng(nomIng ingredient.libelle%TYPE)
AS
CURSOR curPizzaSansIng IS
CURSOR pizzasSansIng IS
SELECT nompiz
FROM pizza
WHERE numpiz NOT IN
......@@ -28,8 +28,8 @@ AS
WHERE LOWER(libelle) = LOWER(nomIng)));
BEGIN
DBMS_OUTPUT.PUT_LINE('Noms des pizzas qui ne contiennent pas de ' || nomIng || ' :');
FOR recPizza IN curPizzaSansIng LOOP
DBMS_OUTPUT.PUT_LINE(' - ' || recPizza.nompiz);
FOR pizza IN pizzasSansIng LOOP
DBMS_OUTPUT.PUT_LINE(' - ' || pizza.nompiz);
END LOOP;
END PizzasSansIng;
......@@ -40,7 +40,7 @@ END PizzasSansIng;
*/
PROCEDURE PizzasSansCat(libCat categorie_ing.libelle%TYPE)
AS
CURSOR curPizzaSansCat IS
CURSOR pizzasSansCat IS
SELECT nompiz
FROM pizza
WHERE numpiz NOT IN
......@@ -55,8 +55,8 @@ AS
WHERE LOWER(libelle) = LOWER(libCat))));
BEGIN
DBMS_OUTPUT.PUT_LINE('Noms des pizzas ne contenant pas de ' || libCat || ' :');
FOR recPizza IN curPizzaSansCat LOOP
DBMS_OUTPUT.PUT_LINE(recPizza.nompiz);
FOR pizza IN pizzasSansCat LOOP
DBMS_OUTPUT.PUT_LINE(' - ' || pizza.nompiz);
END LOOP;
END PizzasSansCat;
......@@ -67,26 +67,25 @@ END PizzasSansCat;
*/
PROCEDURE AfficheCarte
AS
CURSOR curPizzaIng IS
SELECT p.numpiz, INITCAP(p.nompiz) nomPizza,
LISTAGG(i.libelle, ', ') WITHIN GROUP(ORDER BY i.libelle) listeIng
CURSOR pizzasIng IS
SELECT p.numpiz, INITCAP(p.nompiz) nom, LISTAGG(i.libelle, ', ') WITHIN GROUP(ORDER BY i.libelle) listeIng
FROM pizza p
JOIN composition co
ON p.numpiz = co.pizza
JOIN composition c
ON p.numpiz = c.pizza
JOIN ingredient i
ON co.ing = i.numing
ON c.ing = i.numing
GROUP BY p.numpiz, INITCAP(p.nompiz);
CURSOR curTaillePrix(numpiz pizza.numpiz%TYPE) IS
CURSOR lignesTaillePrix(numpiz pizza.numpiz%TYPE) IS
SELECT taille, prix
FROM tarif
WHERE pizza = numpiz
ORDER BY taille;
BEGIN
FOR recPizzaIng IN curPizzaIng LOOP
DBMS_OUTPUT.PUT_LINE('|- ' || recPizzaIng.nomPizza || ' : ' || recPizzaIng.listeIng);
FOR recTaillePrix IN curTaillePrix(recPizzaIng.numpiz) LOOP
DBMS_OUTPUT.PUT_LINE('| |- ' || recTaillePrix.taille || ' personnes : ' || recTaillePrix.prix || ' euros');
FOR pizzaIng IN pizzasIng LOOP
DBMS_OUTPUT.PUT_LINE('|- ' || pizzaIng.nom || ' : ' || pizzaIng.listeIng);
FOR ligneTaillePrix IN lignesTaillePrix(pizzaIng.numpiz) LOOP
DBMS_OUTPUT.PUT_LINE('| |- ' || ligneTaillePrix.taille || ' personnes : ' || ligneTaillePrix.prix || ' euros');
END LOOP;
END LOOP;
END AfficheCarte;
......@@ -99,13 +98,13 @@ END AfficheCarte;
*/
PROCEDURE ModifTarif(numpiz pizza.numpiz%TYPE, taille tarif.taille%TYPE, montant tarif.prix%TYPE)
AS
CURSOR curPrixPizzaPetite IS
CURSOR prixPizzasPlusPetites IS
SELECT prix
FROM tarif
WHERE pizza = numpiz
AND tarif.taille < ModifTarif.taille;
CURSOR curPrixPizzaGrande IS
CURSOR prixPizzasPlusGrandes IS
SELECT prix
FROM tarif
WHERE pizza = numpiz
......@@ -115,13 +114,13 @@ BEGIN
RAISE INVALID_NUMBER;
END IF;
FOR recPrix IN curPrixPizzaPetite LOOP
FOR recPrix IN prixPizzasPlusPetites LOOP
IF (montant < recPrix.prix) THEN
RAISE INVALID_NUMBER;
END IF;
END LOOP;
FOR recPrix IN curPrixPizzaGrande LOOP
FOR recPrix IN prixPizzasPlusGrandes LOOP
IF (montant > recPrix.prix) THEN
RAISE INVALID_NUMBER;
END IF;
......
SET SERVEROUTPUT ON;
SET SERVEROUTPUT ON FORMAT WRAPPED;
CREATE OR REPLACE PACKAGE GestionCommandes IS
PROCEDURE AfficheProchainesCommandes;
......@@ -25,9 +25,9 @@ CREATE OR REPLACE PACKAGE BODY GestionCommandes IS
*/
PROCEDURE AfficheProchainesCommandes
AS
CURSOR curProchainesCommandes IS
CURSOR prochainesCommandes IS
SELECT c.numc, dateheure_cmd, adresse1, adresse2, codepostal, ville,
SUM(l.quantite) qtPiz
SUM(l.quantite) qtePizza
FROM commande c
JOIN ligne_cmd l
ON c.numc = l.numc
......@@ -37,17 +37,17 @@ AS
GROUP BY c.numc, dateheure_cmd,adresse1, adresse2, codepostal, ville
ORDER BY dateheure_cmd;
BEGIN
DBMS_OUTPUT.PUT_LINE('---------------------------------');
FOR cmd IN curProchainesCommandes LOOP
DBMS_OUTPUT.PUT_LINE('Numéro commande : '|| cmd.numc);
DBMS_OUTPUT.PUT_LINE('Quantité de pizzas : '|| cmd.qtPiz);
DBMS_OUTPUT.PUT_LINE('Ville : '|| cmd.ville);
DBMS_OUTPUT.PUT_LINE('Adresse : '||cmd.adresse1);
DBMS_OUTPUT.PUT_LINE('---------------------------------------');
FOR cmd IN prochainesCommandes LOOP
DBMS_OUTPUT.PUT_LINE('Numéro de commande : ' || cmd.numc);
DBMS_OUTPUT.PUT_LINE('Quantité de pizzas : ' || cmd.qtePizza);
DBMS_OUTPUT.PUT_LINE('Ville : ' || cmd.ville);
DBMS_OUTPUT.PUT_LINE('Adresse : ' || cmd.adresse1);
IF cmd.adresse2 IS NOT NULL THEN
DBMS_OUTPUT.PUT_LINE('Complément d''adresse : '|| cmd.adresse2);
DBMS_OUTPUT.PUT_LINE('Complément d''adresse : ' || cmd.adresse2);
END IF;
DBMS_OUTPUT.PUT_LINE('Code postal : '|| cmd.codepostal);
DBMS_OUTPUT.PUT_LINE('---------------------------------');
DBMS_OUTPUT.PUT_LINE('Code postal : ' || cmd.codepostal);
DBMS_OUTPUT.PUT_LINE('---------------------------------------');
END LOOP;
END AfficheProchainesCommandes;
......@@ -81,15 +81,15 @@ RETURN REAL
AS
cout REAL;
CURSOR curLigneCmd IS
CURSOR lignesCmd IS
SELECT numc, tarif
FROM ligne_cmd
WHERE numc = numcom;
BEGIN
cout := 0;
FOR recLigneCmd IN curLigneCmd LOOP
cout := cout + CoutLigneCommande(recLigneCmd.numc, recLigneCmd.tarif);
FOR ligneCmd IN lignesCmd LOOP
cout := cout + CoutLigneCommande(ligneCmd.numc, ligneCmd.tarif);
END LOOP;
RETURN cout;
......@@ -104,15 +104,15 @@ RETURN REAL
AS
gain REAL;
CURSOR curCmdJour IS
CURSOR commandesJour IS
SELECT numc
FROM commande
WHERE TO_CHAR(dateheure_cmd, 'DD/MM/YYYY') = TO_CHAR(jour, 'DD/MM/YYYY');
BEGIN
gain := 0;
FOR recCmdJour IN curCmdJour LOOP
gain := gain + CoutCommande(recCmdJour.numc);
FOR cmdJour IN commandesJour LOOP
gain := gain + CoutCommande(cmdJour.numc);
END LOOP;
RETURN gain;
......@@ -181,18 +181,18 @@ BEGIN
DBMS_OUTPUT.PUT_LINE(' PIZZERIA PRONTO ');
DBMS_OUTPUT.PUT_LINE('===============================================');
DBMS_OUTPUT.PUT_LINE('Commande n° ' || numcom || ' Date : ' || TO_CHAR(datec, 'DD/MM/YYYY'));
DBMS_OUTPUT.PUT_LINE('Commande n° ' || numcom || ' Date : ' || TO_CHAR(datec, 'DD/MM/YYYY'));
DBMS_OUTPUT.PUT_LINE('===============================================');
DBMS_OUTPUT.PUT_LINE('Pizza (taille) Qté P.U. Total av. rem. Remise Total ap. remise');
DBMS_OUTPUT.PUT_LINE('Piz. (tail.) Qté PU Total av.r Rem. Total ap.r');
DBMS_OUTPUT.PUT_LINE('-----------------------------------------------');
FOR lf IN lignesFacture LOOP
DBMS_OUTPUT.PUT_LINE(lf.pizza || ' (' || lf.taille ||
' pers.) ' || lf.qte || ' ' || lf.pu || ' ' ||
' pers.) ' || lf.qte || ' ' || lf.pu || ' ' ||
lf.total_pre_r || ' ' || lf.remise || ' ' || lf.total);
END LOOP;
DBMS_OUTPUT.PUT_LINE('===============================================');
DBMS_OUTPUT.PUT_LINE('Total avec remise : ' || CoutCommande(numcom));
DBMS_OUTPUT.PUT_LINE('Remise : ' || (CoutCommande(numcom) - total));
DBMS_OUTPUT.PUT_LINE('Remise : ' || (total - CoutCommande(numcom)));
END Facture;
/*
......@@ -202,9 +202,11 @@ END Facture;
*/
PROCEDURE MeilleureCommandeMoisCourant
AS
-- on utlise un cursor pour pouvoir afficher plusieurs commandes dans le cas
-- où il ya plusieurs meilleures commandes !
CURSOR curMeilleuresCmd IS
/*
* On utlise un curseur pour pouvoir afficher plusieurs commandes dans
* le cas où il y a plusieurs meilleures commandes.
*/
CURSOR meilleuresCmd IS
SELECT numc, CoutCommande(numc) cout
FROM commande
WHERE TO_CHAR(SYSDATE, 'MM/YYYY') = TO_CHAR(dateheure_cmd, 'MM/YYYY')
......@@ -213,13 +215,12 @@ AS
FROM commande
WHERE TO_CHAR(SYSDATE, 'MM/YYYY') = TO_CHAR(dateheure_cmd, 'MM/YYYY'));
BEGIN
DBMS_OUTPUT.PUT_LINE('---------------------------------');
FOR meilleureCmd IN curMeilleuresCmd LOOP
DBMS_OUTPUT.PUT_LINE('---------------------------------------');
FOR meilleureCmd IN meilleuresCmd LOOP
DBMS_OUTPUT.PUT_LINE('Meilleure commande du mois : ' || meilleureCmd.numc);
DBMS_OUTPUT.PUT_LINE('Avec un coût de : ' || meilleureCmd.cout);
DBMS_OUTPUT.PUT_LINE('---------------------------------');
DBMS_OUTPUT.PUT_LINE('---------------------------------------');
END LOOP;
END MeilleureCommandeMoisCourant;
END;
/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment