MySQL - Trigger con Mysql5.0

 
Vista:
Imágen de perfil de RTB

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.-
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Trigger con Mysql5.0

Publicado por kain (124 intervenciones) el 29/03/2007 19:04:33
prueba de esta manera:

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
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de rtb

RE:Trigger con Mysql5.0

Publicado por rtb (5 intervenciones) el 31/05/2007 13:46:23
Gracias José por contestar mi mensaje, pero me sigue dando el mismo error, no puedo crear el trigger.-
Roberto
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Trigger fron the web

Publicado por Mauricio (1 intervención) el 27/11/2007 04:41:09
How can I do a trigger from the web?

I need the code.

It is urgent please.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar