Ayuda trigger
Publicado por Luis (1 intervención) el 14/02/2008 22:39:35
Me sale un error al ejecutar el trigger
CREATE TABLE `documento` (
`IdDocumento` decimal(9,0) NOT NULL,
`IdRadicado` decimal(7,0) NOT NULL,
`Fecha` date NOT NULL,
`Ciudad` varchar(18) NOT NULL,
`Asunto` varchar(50) NOT NULL,
PRIMARY KEY (`IdDocumento`)
) ;
CREATE TRIGGER consecutivo_doc
BEFORE
INSERT ON Documento
FOR EACH ROW
BEGIN
DECLARE maxrad INT;
SELECT INTO SET maxrad = MAX(idRadicado) FROM Documento
WHERE idTipoDocumento=NEW.idTipoDocumento and YEAR(fecha)=YEAR(NEW.fecha);
IF maxrad!=null THEN NEW.idRadicado=@maxrad+1;
ELSE NEW.idRadicado=1;
END IF;
END;
ERROR 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 'INT' at line 6
ERROR 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 'INTO SET maxrad = MAX(idRadicado) FROM Documento
WHERE idTipoDocumento=NEW.idTi' at line 1
ERROR 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 'IF maxrad!=null THEN NEW.idRadicado=@maxrad+1' at line 1
ERROR 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 'ELSE NEW.idRadicado=1' at line 1
ERROR 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 'END IF' at line 1
ERROR 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 'END' at line 1
CREATE TABLE `documento` (
`IdDocumento` decimal(9,0) NOT NULL,
`IdRadicado` decimal(7,0) NOT NULL,
`Fecha` date NOT NULL,
`Ciudad` varchar(18) NOT NULL,
`Asunto` varchar(50) NOT NULL,
PRIMARY KEY (`IdDocumento`)
) ;
CREATE TRIGGER consecutivo_doc
BEFORE
INSERT ON Documento
FOR EACH ROW
BEGIN
DECLARE maxrad INT;
SELECT INTO SET maxrad = MAX(idRadicado) FROM Documento
WHERE idTipoDocumento=NEW.idTipoDocumento and YEAR(fecha)=YEAR(NEW.fecha);
IF maxrad!=null THEN NEW.idRadicado=@maxrad+1;
ELSE NEW.idRadicado=1;
END IF;
END;
ERROR 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 'INT' at line 6
ERROR 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 'INTO SET maxrad = MAX(idRadicado) FROM Documento
WHERE idTipoDocumento=NEW.idTi' at line 1
ERROR 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 'IF maxrad!=null THEN NEW.idRadicado=@maxrad+1' at line 1
ERROR 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 'ELSE NEW.idRadicado=1' at line 1
ERROR 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 'END IF' at line 1
ERROR 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 'END' at line 1
Valora esta pregunta


0