
Trigger con Mysql5.0
Publicado por RTB (5 intervenciones) el 28/03/2007 14:15:44
Hola a todos, un novato en mysql5.0 necesita ayuda con triggers , estoy necesitando crearlos y me da el siguiente error
Error Code : 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 'UPDATE creditos
SET importe=importe+NEW.importe
WHERE id_credito=NEW.id_cred' at line 4
(15 ms taken)
Error Code : 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
(0 ms taken)
el trigger que quiero hacer es sencillo,
DELIMITER $$;
CREATE TRIGGER trg_cuotas_inser BEFORE INSERT on cuotas
FOR EACH ROW
BEGIN
UPDATE creditos
SET importe=importe+NEW.importe
WHERE id_credito=NEW.id_credito$$
end$$
DELIMITER ;$$
Las tablas son Creditos
creditos CREATE TABLE `creditos` (
`id_credito` varchar(15) NOT NULL,
`Importe_concedido` decimal(10,0) default NULL,
`id_persona` decimal(10,0) default NULL,
PRIMARY KEY (`id_credito`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
la tabla cuotas es:
cuotas CREATE TABLE `cuotas` (
`id_credito` varchar(20) NOT ULL,
`numero_cuota` int(11) NOT NULL,
`Estado_cuota` char(1) NOT NULL,
`importe` decimal(10,0) NOT NULL default '0',
KEY `cnt_cuotas_pk` (`id_credito`),
CONSTRAINT `cnt_cuotas_pk` FOREIGN KEY (`id_credito`) REFERENCES `creditos` (`id_credito`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Gracias.-
Error Code : 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 'UPDATE creditos
SET importe=importe+NEW.importe
WHERE id_credito=NEW.id_cred' at line 4
(15 ms taken)
Error Code : 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
(0 ms taken)
el trigger que quiero hacer es sencillo,
DELIMITER $$;
CREATE TRIGGER trg_cuotas_inser BEFORE INSERT on cuotas
FOR EACH ROW
BEGIN
UPDATE creditos
SET importe=importe+NEW.importe
WHERE id_credito=NEW.id_credito$$
end$$
DELIMITER ;$$
Las tablas son Creditos
creditos CREATE TABLE `creditos` (
`id_credito` varchar(15) NOT NULL,
`Importe_concedido` decimal(10,0) default NULL,
`id_persona` decimal(10,0) default NULL,
PRIMARY KEY (`id_credito`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
la tabla cuotas es:
cuotas CREATE TABLE `cuotas` (
`id_credito` varchar(20) NOT ULL,
`numero_cuota` int(11) NOT NULL,
`Estado_cuota` char(1) NOT NULL,
`importe` decimal(10,0) NOT NULL default '0',
KEY `cnt_cuotas_pk` (`id_credito`),
CONSTRAINT `cnt_cuotas_pk` FOREIGN KEY (`id_credito`) REFERENCES `creditos` (`id_credito`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Gracias.-
Valora esta pregunta


0