MySQL Forums
Forum List  »  Spanish

CREACION DE (DISPARADOR) TRIGGER- Error #1054...NEW es desconocida
Posted by: Alcy Salazar Martínez
Date: March 12, 2019 12:58PM

Hola muy buenas tardes para todos,

estoy creando un disparador para administrar el tema de auditoria, y al tratar de crearlo me sale error, el cual no entiendo, por favor alguien me puede indicar por que...
Muchas Gracias... ;-)

Tengo esta tabla principal...

CREATE TABLE `datos_personales` (
`id` char(36) NOT NULL,
`alive` tinyint(1) NOT NULL,
`apellido1` varchar(255) NOT NULL,
`apellido2` varchar(255) DEFAULT NULL,
`nombre1` varchar(255) DEFAULT NULL,
`nombre2` varchar(255) DEFAULT NULL,
`genero` varchar(255) DEFAULT NULL,
`cod_dpto_nacimiento` varchar(255) DEFAULT NULL,
`cod_mpio_nacimiento` varchar(255) DEFAULT NULL,
`fecha_nacimiento` date DEFAULT NULL,
`estado_conyugal` varchar(255) DEFAULT NULL,
`cod_pais_residencia` varchar(255) DEFAULT NULL,
`cod_dpto_residencia` varchar(255) DEFAULT NULL,
`cod_mpio_residencia` varchar(255) DEFAULT NULL,
`direccion_domicilio` varchar(255) DEFAULT NULL,
`telefono` varchar(255) DEFAULT NULL,
`telefono_movil` varchar(255) DEFAULT NULL,
`cod_grupo_etnico` varchar(255) DEFAULT NULL,
`created` datetime NOT NULL,
`modified` datetime NOT NULL,
`user_id` char(36) DEFAULT NULL,
`cod_pais_nacimiento` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



Este es el TRIGGER que estoy creando.

CREATE TRIGGER `DATOS_PERSONALES_AI` AFTER INSERT ON `datos_personales`
FOR EACH ROW INSERT INTO audit_datos_personales (id_datos_personales, alive, apellido1, apellido2, nombre1, nombre2, genero, cod_dpto_nacimiento, cod_mpio_nacimiento, fecha_nacimiento, estado_conyugal, cod_dpto_residencia, cod_mpio_residencia,
direccion_domicilio, telefono, telefono_movil, cod_grupo_etnico, cod_pais_nacimiento, creado_por, fecha_creacion, creado_por,
fecha_creacion, proceso_realizado)
VALUES(NEW.id_datos_personales, NEW.alive, NEW.apellido1, NEW.apellido2, NEW.nombre1, NEW.nombre2, NEW.genero, NEW.cod_dpto_nacimiento,NEW.cod_mpio_nacimiento, NEW.fecha_nacimiento, NEW.estado_conyugal, NEW.cod_dpto_residencia, NEW.cod_mpio_residencia, NEW.direccion_domicilio, NEW.telefono, NEW.telefono_movil, NEW.cod_grupo_etnico, NEW.cod_pais_nacimiento, CURRENT_USER(), CURRENT_TIMESTAMP, 'INSERT - NUEVO')



El error que sale es el siguiente.

#1054 - La columna 'id_datos_personales' en NEW es desconocida.



Esta es la tabla en la cual voy a guardar la información insertada en la tabla principal.

CREATE TABLE `audit_datos_personales` (
`id` int(11) NOT NULL,
`id_datos_personales` varchar(255) DEFAULT NULL,
`alive` tinyint(4) DEFAULT NULL,
`apellido1` varchar(255) DEFAULT NULL,
`apellido2` varchar(255) DEFAULT NULL,
`nombre1` varchar(255) DEFAULT NULL,
`nombre2` varchar(255) DEFAULT NULL,
`genero` varchar(255) DEFAULT NULL,
`cod_dpto_nacimiento` varchar(255) DEFAULT NULL,
`cod_mpio_nacimiento` varchar(255) DEFAULT NULL,
`fecha_nacimiento` date DEFAULT NULL,
`estado_conyugal` varchar(255) DEFAULT NULL,
`cod_dpto_residencia` varchar(255) DEFAULT NULL,
`cod_mpio_residencia` varchar(255) DEFAULT NULL,
`direccion_domicilio` varchar(255) DEFAULT NULL,
`telefono` varchar(255) DEFAULT NULL,
`telefono_movil` varchar(255) DEFAULT NULL,
`cod_grupo_etnico` varchar(255) DEFAULT NULL,
`cod_pais_nacimiento` varchar(255) DEFAULT NULL,
`creado_por` varchar(255) NOT NULL,
`fecha_creacion` date NOT NULL,
`proceso_realizado` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='TABLA QUE CONTIENE LA INFORMACIÓN QUE INGRESARON EN LA TABLA DE DATOS PERSONALES, POR CUALQUIER USUARIO.';



Muchas Gracias por su colaboración.

Options: ReplyQuote


Subject
Views
Written By
Posted
CREACION DE (DISPARADOR) TRIGGER- Error #1054...NEW es desconocida
1611
March 12, 2019 12:58PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.