Bonjour les spécialistes MySQL!
Je cherche a faire un trigger qui refuse les enregistrements si

->si la SESSION existe déjà et que tous les autres champs sont identiques

pour l'instant j'ai ce code


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
|
CREATE TRIGGER chck4session_unik 
BEFORE INSERT 
ON pan_tmp_select.SESSION
FOR EACH ROW
 
 
BEGIN
DECLARE exist_session INTEGER;
DECLARE ERR_PERSO CONDITION FOR -1001;
DECLARE SESSION_OUI INTEGER;
 
DECLARE EXIT HANDLER FOR ERR_PERSO SET @error = 'Cet enregistrement est deja selectionne';
 
SELECT COUNT(*) INTO SESSION_OUI FROM `pan_tmp_select` WHERE SESSION = NEW.SESSION;
 
IF (SESSION_OUI>0) THEN
SIGNAL ERR_PERSO;
END IF;
END;
 |
MON ERREUR MySQL:
MySQL a réponduocumentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1001;
DECLARE SESSION_OUI INTEGER;

DECLARE EXIT HANDLER FOR ERR_PERSO SET @' at line 9

Voici la structure de ma table

Champs type
x int(6)
y char(19)
z int(6)
a char(19)
b char(8)
c tinyint(1)
SESSION varchar(256)




Si quelqu'un à une idée pour m'aider !!

Merci beaucoup.