Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/12/2007, 11:41
August
 
Fecha de Ingreso: febrero-2005
Mensajes: 626
Antigüedad: 19 años, 2 meses
Puntos: 10
Alguien me ayuda con TRIGGERS

Hola Amigos deL CLUB DE COSITAS DEL MySQL

He intentado lo siguiente pero no me funciona


Código PHP:
SELECT IF(((SELECT COUNT( * ) FROM `cpupreordenWHERE `ordencompra` = '18066100554753d281877d15.06587328' GROUP BY `ordencompra` ) >0), ''INSERT INTO `cpupreorden` (`id`, 

`
user`, `modelo`, `componente`, `ide`, `precio`, `ordencompra`, `fecha`) VALUES (1'Augustino''1''Gabinete'155'286183694753bd5b9935b4.09133438''2007-12-03 

03:45:52'
)) 
#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 `cpupreorden` (`id`,

`user`, `modelo`, `componente`, `ide`, `precio`, `' at line 1

Código PHP:
CREATE TRIGGER 'inser' BEFORE INSERT ON `cpupreorden`;
BEGIN
DECLARE
    @
numres int,
    FOR 
EACH ROW 
    BEGIN
        SELECT 
@numres COUNT( * ) FROM `cpupreordenWHERE `ordencompra` = '18066100554753d281877d15.06587328' GROUP BY `ordencompra`;
    IF @
numres '0'
        
BEGIN
            INSERT INTO 
`cpupreorden` ( `id` , `user` , `modelo` , `componente` , `ide` , `precio` , `ordencompra` , `fecha` )
VALUES (
'''Augustino''1''Gabinete''1''55''18066100554753d281877d15.06587328'now( ));
        
END;
     
END;
    
END
#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 'DECLARE
@numres int