tp2Imunes - devMadelaine - Q1ControleBlancDev32
This commit is contained in:
1
BD/Lekpa/.##connectDB#
Symbolic link
1
BD/Lekpa/.##connectDB#
Symbolic link
@@ -0,0 +1 @@
|
||||
lekpa@morinl.3345:1669890146
|
BIN
BD/Lekpa/PLSQL_cours.pdf
Normal file
BIN
BD/Lekpa/PLSQL_cours.pdf
Normal file
Binary file not shown.
@@ -82,6 +82,7 @@ la contrainte de suppression en cascade
|
||||
|
||||
exercice 6
|
||||
|
||||
// faire manuellement (car la suppression ne marche pas)
|
||||
drop table Client cascade constraints;
|
||||
drop table Commande cascade constraints;
|
||||
drop table ligne_commande cascade constraints;
|
||||
@@ -116,3 +117,34 @@ CREATE TABLE ligne_commande (
|
||||
|
||||
Exercice 7
|
||||
|
||||
create table CommandeAuditLog(
|
||||
Utilisateur VARCHAR(255),
|
||||
ActionSQL VARCHAR(3) CONSTRAINT type_enumere_requette CHECK (ActionSQL IN ('INS', 'DEL', 'UDP')),
|
||||
DateMAJ DATE,
|
||||
ActCol VARCHAR(255)
|
||||
);
|
||||
|
||||
CREATE OR REPLACE TRIGGER insertionCommandeAuditLog
|
||||
AFTER INSERT OR DELETE OR UPDATE
|
||||
ON Commande
|
||||
FOR EACH ROW
|
||||
DECLARE
|
||||
CURSOR c_attribut IS SELECT column_name FROM user_tab_columns WHERE table_name = 'COMMANDE';
|
||||
nom_colonne VARCHAR(255);
|
||||
BEGIN
|
||||
IF INSERTING THEN
|
||||
INSERT INTO CommandeAuditLog VALUES (USER, 'INS', SYSDATE, null);
|
||||
ELSIF DELETING THEN
|
||||
INSERT INTO CommandeAuditLog VALUES (USER, 'DEL', SYSDATE, null);
|
||||
ELSIF UPDATING THEN
|
||||
OPEN c_attribut;
|
||||
LOOP
|
||||
FETCH c_attribut INTO nom_colonne ;
|
||||
IF UPDATING(nom_colonne) THEN
|
||||
INSERT INTO CommandeAuditLog VALUES (USER, 'UDP', SYSDATE, nom_colonne);
|
||||
END IF;
|
||||
EXIT WHEN c_attribut%NOTFOUND;
|
||||
END LOOP;
|
||||
CLOSE c_attribut;
|
||||
END IF;
|
||||
END combinedTrigger;
|
Reference in New Issue
Block a user