Trigger funktioniert nicht

rebelhig

Benutzer
Beiträge
16
Hallo,

ich habe folgenden Trigger geschrieben, jedoch passiert nichts:

Code:
CREATE DEFINER=`root`@`localhost` TRIGGER `insertMails` BEFORE INSERT ON `dbmail_header` FOR EACH ROW BEGIN

DECLARE res_pmid BIGINT;
DECLARE res_pathid BIGINT;
DECLARE res_email VARCHAR(150);
DECLARE done INT DEFAULT FALSE;

DECLARE curnamereturnpath CURSOR FOR SELECT id FROM dbmail_header WHERE headername LIKE 'return-path';

DECLARE curvaluesreturnpath CURSOR FOR SELECT dv.headervalue FROM dbmail_headervalue dv
    JOIN dbmail_header dh on physmessage_id=res_pmid AND headername_id=res_pathid
    WHERE dv.id=dh.headervalue_id LIMIT 1;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

SET res_pmid = NEW.physmessage_id;
SET res_email = '';

OPEN curnamereturnpath;
    FETCH curnamereturnpath INTO res_pathid;
    IF NOT done THEN
    OPEN curvaluesreturnpath;
        block2: BEGIN
            DECLARE donepath INT DEFAULT FALSE;
            DECLARE CONTINUE HANDLER FOR NOT FOUND SET donepath = TRUE;
           
            FETCH curvaluesreturnpath INTO res_email;
            IF NOT donepath THEN
                CALL insertInDummy(res_email,res_pmid);
            END IF;
           
        END block2;
    CLOSE curvaluesreturnpath;
    END IF;

CLOSE curnamereturnpath;

END

Könnt ihr mir hier weiterhelfen?
Gruß
Reiner
 
Werbung:
Zurück
Oben