Skip to content
Snippets Groups Projects
Commit 5640231c authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Modification du message pour un code utilisateur déjà utilisé

parent 5b14029d
No related branches found
No related tags found
No related merge requests found
CREATE OR REPLACE TRIGGER "INTERVENANT_CK" CREATE
BEFORE INSERT OR UPDATE OF source_id, source_code, histo_destruction, code, statut_id, utilisateur_code ON intervenant OR REPLACE TRIGGER "INTERVENANT_CK"
BEFORE INSERT OR
UPDATE of source_id, source_code, histo_destruction, code, statut_id, utilisateur_code
ON intervenant
FOR EACH ROW FOR EACH ROW
DECLARE DECLARE
pragma autonomous_transaction; pragma autonomous_transaction;
imp NUMERIC; imp
cs NUMERIC; NUMERIC;
cs
NUMERIC;
BEGIN BEGIN
IF :NEW.histo_destruction IS NOT NULL THEN IF
:NEW.histo_destruction IS NOT NULL THEN
RETURN; RETURN;
END IF; END IF;
SELECT importable INTO imp FROM source WHERE id = :NEW.SOURCE_ID; SELECT importable
IF imp = 1 THEN INTO imp
FROM source
WHERE id = :new.source_id;
IF
imp = 1 THEN
-- Contrôle du bon remplissage du source_code -- Contrôle du bon remplissage du source_code
IF :NEW.source_code IS NULL THEN IF :NEW.source_code IS NULL THEN
...@@ -21,25 +31,33 @@ BEGIN ...@@ -21,25 +31,33 @@ BEGIN
END IF; END IF;
-- Contrôle de l'unicité de STATUT_ID -- Contrôle de l'unicité de STATUT_ID
SELECT COUNT(*) INTO cs FROM INTERVENANT WHERE SELECT COUNT(*)
id <> :NEW.id AND histo_destruction IS NULL INTO cs
AND code = :NEW.code FROM intervenant
AND annee_id = :NEW.annee_id WHERE id <> :new.id
AND statut_id = :NEW.statut_id AND histo_destruction IS NULL
AND code = :new.code
AND annee_id = :new.annee_id
AND statut_id = :new.statut_id
; ;
IF cs > 0 THEN IF
cs > 0 THEN
raise_application_error(-20101, 'Un intervenant ne peut pas avoir deux fois le même statut le même année'); raise_application_error(-20101, 'Un intervenant ne peut pas avoir deux fois le même statut le même année');
END IF; END IF;
-- On ne peut pas assicoer un même login à plusieurs intervenants -- On ne peut pas assicoer un même login à plusieurs intervenants
SELECT COUNT(*) INTO cs FROM INTERVENANT WHERE SELECT COUNT(*)
id <> :NEW.id AND histo_destruction IS NULL INTO cs
AND code <> :NEW.code FROM intervenant
AND annee_id = :NEW.annee_id WHERE id <> :new.id
AND utilisateur_code = :NEW.utilisateur_code AND histo_destruction IS NULL
AND code <> :new.code
AND annee_id = :new.annee_id
AND utilisateur_code = :new.utilisateur_code
; ;
IF cs > 0 THEN IF
raise_application_error(-20101, 'L''utilisateur est déjà utilisé pour un autre intervenant. Merci d''en choisir un autre.'); cs > 0 THEN
raise_application_error(-20101, 'L''utilisateur est déjà utilisé pour un autre intervenant. Merci d''en choisir un autre.' || ' Pour le nouveau dossier ID: '|| :NEW.id|| ', Code: '|| :NEW.code || ', utilisateur_code: '||:NEW.utilisateur_code );
END IF; END IF;
END; END;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment