Ver Mensaje Individual
  #2 (permalink)  
Antiguo 21/03/2009, 09:06
msantilliyo
 
Fecha de Ingreso: julio-2006
Ubicación: 127.0.0.1
Mensajes: 14
Antigüedad: 20 años, 3 meses
Puntos: 0
Respuesta: Problemas con un IF en mysql

encontre la solucion, esta sentencia me funciona OK!!

lo dejo por si alquien tuvo el mismo problema que yo

este trigger ademas agrega un * al principio del campo editado para tener un control de la información que edito un determinado usuario

Código PHP:
create trigger eliminar_modificar_chofer after update on choferes 
for each row 

begin

declare mov text;
declare 
ape text;
declare 
nom text;
declare 
tel text;
declare 
cli text;

set ape= new.Apellido;
set cli= new.IdCliente;
set nom= new.Nombre;
set tel= new.Telefono;

if new.
Estado > 0 then 
set mov
= 'Baja'; 
else 

set mov='Modificacion'; 
if 
strcmp(new.Apellido, old.Apellido) <> 0 then set ape = concat('*', new.Apellido); end if;
if 
strcmp(new.Nombre, old.Nombre) <> 0 then set nom = concat('*', new.Nombre); end if;
if 
strcmp(new.Telefono, old.Telefono) <> 0 then set tel = concat('*', new.Telefono); end if;
if 
strcmp(new.IdCliente, old.IdCliente) <> 0 then set cli = concat('*', new.IdCliente); end if;

end if;

insert into choferes_auditoria (IdChofer, IdCliente, Apellido, Nombre, Telefono, IdUser, Fecha, Movimiento) values(new.IdChofer, cli,ape, nom, tel, new.IdUser, now(), mov);

end