Ajout des tp
This commit is contained in:
26
TP_BD/fichiereponsetp3.sql
Normal file
26
TP_BD/fichiereponsetp3.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
--sqlplus "val@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=lorien.arda.lan)(Port=1521))(CONNECT_DATA=(SID=ORCLIUT)))"
|
||||
|
||||
1. CREATE OR REPLACE PROCEDURE sp_DateDernierAchat(Nom_Produit VARCHAR)
|
||||
IS
|
||||
v_date_recent DATE;
|
||||
BEGIN
|
||||
Select MAX(date_achat) INTO v_date_recent FROM Commande c JOIN ligne_commande lc ON c.id=lc.commande_id JOIN Produit p ON lc.produit_id=p.id where p.nom_produit=Nom_Produit;
|
||||
DBMS_OUTPUT.PUT_LINE('le produit '||Nom_Produit||' a pour dernière '||v_date_recent);
|
||||
END sp_DateDernierAchat;
|
||||
|
||||
2. ALTER TABLE Produit add quantite_en_stock number DEFAULT 10;
|
||||
|
||||
3. CREATE OR REPLACE TRIGGER trg_GestionStock
|
||||
BEFORE INSERT
|
||||
ON ligne_commande lc
|
||||
FOR EACH ROW
|
||||
v_quantite number;
|
||||
BEGIN
|
||||
SELECT quantite_en_stock into v_quantite from Produit p where p.id=ligne_commande.produit
|
||||
IF:new.quantite<=v_quantite
|
||||
UDAPTE Produit p
|
||||
p_commande_id
|
||||
SET
|
||||
--WHEN (new.quatite<=quantite_en_stock)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user