1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| show err;
CREATE OR REPLACE PROCEDURE
imprimer_facture(numcom IN Commandes.num_com%TYPE)
IS
taux float;
-- Variable pour l'affichage de l''entête de la facture
numeroclient Clients.num_cli%TYPE;
nomclient Clients.nom_cli%TYPE;
adresseclient Clients.adress_cli%TYPE;
telephoneclient Clients.numtel_cli%TYPE;
datecommande Commandes.date_com%TYPE;
-- Variables dans MonCurseur pour l'affichage dans la facture
numeroproduit Produits.num_pro%TYPE;
libelleproduit Produits.lib_pro%TYPE;
quantitecommade Ligne_Coms.qte_com%TYPE;
prix_unitaire Produits.prix_u%TYPE;
prixproduit Produits.prix_u%TYPE;
MontantTotal Commandes.mtot_com%TYPE;
-- Déclaration du curseur
CURSOR MonCurseur
IS
SELECT* FROM Commandes,Produits,Clients,Ligne_Coms
WHERE Commandes.num_com = numcom
AND Clients.num_cli = Commandes.num_com
AND Ligne_Coms.num_com = Commandes.num_com
AND Produits.num_pro = Ligne_Coms.num_pro
ORDER BY Produits.num_pro asc;--ligne 28
BEGIN
taux:=0.18;
-- Pour l'affichage de l'entête de la facture
SELECT Clients.num_cli,Clients.nom_cli,Clients.adress_cli,Clients.numtel_cli,Commandes.Mtot_Com,Commandes.date_com
INTO numeroclient,nomclient,adresseclient,telephoneclient,MontantTotal,datecommande
FROM Commandes,Produits,Clients,Ligne_Coms
WHERE Commandes.num_com = numcom
AND Clients.num_cli = Commandes.num_com
AND Ligne_Coms.num_com = Commandes.num_com
AND Produits.num_pro = Ligne_Coms.num_pro;
-- Affichage de l'entête de la facture
DBMS_OUTPUT.PUT_LINE('Client N° :'||numeroclient);
DBMS_OUTPUT.PUT_LINE('Nom :'||nomclient);
DBMS_OUTPUT.PUT_LINE('Adresse :'||adresseclient);
DBMS_OUTPUT.PUT_LINE('Telephone :'||telephoneclient);
DBMS_OUTPUT.PUT_LINE('______________________________________________________________________________________________________________');
-- Affichage du numero et de la date de la commande
DBMS_OUTPUT.PUT_LINE('Commande N° :'||numcom);
DBMS_OUTPUT.PUT_LINE('Du :'||datecommande);
-- Affichage des entêtes concernant les différents produits de la facture
DBMS_OUTPUT.PUT_LINE('Prod N° | Libelle | QteCom | Prix Unitaire | Prix Prod | TVA ');
OPEN MonCurseur;
-- FETCH MonCurseur INTO numeroproduit,libelleproduit,quantitecommade,prix_unitaire;
--WHILE (MonCurseur%FOUND)
LOOP
FETCH MonCurseur INTO numeroproduit,libelleproduit,quantitecommade,prix_unitaire;
prixproduit:=quantitecommade*(prix_unitaire + taux); -- Calcul du prix du produit
DBMS_OUTPUT.PUT_LINE(numeroproduit||'--'||libelleproduit||'--'||quantitecommade||'--'||prix_unitaire||'--'||prixproduit||'--'||taux);
END LOOP;
CLOSE MonCurseur;
DBMS_OUTPUT.PUT_LINE('MONTANT TOTAL :'|| MontantTotal ||'FCFA');
END ; |
Partager