base_de_donnees_xml.py

Created by joelkouakou2080

Created on March 12, 2024

2.04 KB


exo 4
CREATE OR REPLACE TRIGGER plafond_operations
BEFORE INSERT ON operations
FOR EACH ROW
DECLARE
    v_montant_total NUMBER;
BEGIN
    -- Calculer le montant total des opérations pour le mois en cours
    SELECT SUM(montant) INTO v_montant_total
    FROM operations
    WHERE employee_id = :NEW.employee_id
    AND EXTRACT(MONTH FROM date_operation) = EXTRACT(MONTH FROM SYSDATE)
    AND EXTRACT(YEAR FROM date_operation) = EXTRACT(YEAR FROM SYSDATE);
    
    -- Vérifier si le montant total des opérations dépasse le plafond
    IF v_montant_total + :NEW.montant > 1000000 THEN
        RAISE_APPLICATION_ERROR(-20001, 'Les opérations mensuelles sont plafonnées à 1 million FCFA.');
    END IF;
END;
/
------------------------------
exo 5
CREATE OR REPLACE TRIGGER verifier_date_operation
BEFORE INSERT ON operations
FOR EACH ROW
DECLARE
    v_date_creation DATE;
BEGIN
    -- Récupérer la date de création du compte client
    SELECT date_creation INTO v_date_creation
    FROM clients
    WHERE client_id = :NEW.client_id;
    
    -- Vérifier si la date de l'opération est antérieure à la date de création du compte
    IF :NEW.date_operation < v_date_creation THEN
        RAISE_APPLICATION_ERROR(-20002, 'La date de l''opération est antérieure à la date de création du compte client.');
    END IF;
END;
/
---------------------------
exo 6
CREATE OR REPLACE PACKAGE operations_package AS
    PROCEDURE plafond_operations;
    PROCEDURE verifier_date_operation;
    -- Autres procédures ou fonctions nécessaires
END operations_package;
/

CREATE OR REPLACE PACKAGE BODY operations_package AS
    PROCEDURE plafond_operations IS
    BEGIN
        -- Code du déclencheur plafond_operations
        -- (copier le code du déclencheur ici)
    END plafond_operations;

    PROCEDURE verifier_date_operation IS
    BEGIN
        -- Code du déclencheur verifier_date_operation
        -- (copier le code du déclencheur ici)
    END verifier_date_operation;

    -- Autres procédures ou fonctions nécessaires
END operations_package;
/

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.