How to make a trigger in mysql that I update the data of a bitmap when ejecting another trigger from insert -


i working on project in php have audit of database of changes. have table table stored changes of person table

create table `personas` (   `cedula` varchar(13) not null,   `nombres` varchar(30) not null,   `apellidos` varchar(20) not null,   `sexo` varchar(10) not null,   `telefono` varchar(20) not null,   `direccion` text not null,   `fnacimiento` date not null ) engine=innodb default charset=utf8; 

and have users table

create table `usuarios` (   `id` int(10) not null,   `correo` varchar(80) default null,   `usuario` varchar(10) default null,   `password` varchar(100) default null,   `last_session` datetime default null,   `activacion` int(15) not null default '0',   `token` varchar(40) not null,   `token_password` varchar(100) not null,   `password_request` int(11) not null default '0',   `id_tipo` varchar(20) default null,   `usuarios_cedula` varchar(13) default null ) engine=innodb default charset=utf8; 

the logbook follows

create table `bitacorapersonas` (   `idbitacora` int(20) not null,   `accion` varchar(20) not null,   `fecha` datetime not null,   `cedusuario` varchar(20) default null,   `nombreusuario` varchar(13) not null,   `tipousuario` varchar(15) not null,   `cedula` varchar(13) not null,   `nombrenuevo` varchar(25) default null,   `nombreviejo` varchar(20) default null,   `apellidonuevo` varchar(30) not null,   `apellidoviejo` varchar(30) default null,   `sexonuevo` varchar(10) not null,   `sexoviejo` varchar(10) default null,   `telefononuevo` varchar(15) not null,   `telefonoviejo` varchar(15) default null,   `direccionnuevo` varchar(40) not null,   `direccionviejo` varchar(40) default null,   `fnacimientonuevo` date not null,   `fnacimientoviejo` date default null,   `usuarionuevo` varchar(15) not null,   `correonuevo` varchar(15) not null,   `correoviejo` varchar(15) not null ) engine=innodb default charset=utf8; 

in people table , user table have trigger each one. presenting following: when enter person data divided 2 rows apart instead of placing them in single (for being same person entering)

the triggers follows

create trigger `personas_ainsertar` after insert on `personas`  each row      insert bitacorapersonas (accion,fecha,cedusuario, nombreusuario,tipousuario,cedula,nombrenuevo,apellidonuevo,sexonuevo,telefononuevo,direccionnuevo,fnacimientonuevo)      values ('inserto',now(),@identificador,@identificador2,@identificador3,new.cedula,new.nombres,new.apellidos,new.sexo,new.telefono, new.direccion,new.fnacimiento)  create trigger `usuarios_ainsertar` after insert on `usuarios`  each row      insert bitacorapersonas (accion,fecha,cedusuario, nombreusuario,tipousuario, usuarionuevo,correonuevo)      values ('inserto',now(),@identificador,@identificador2,@identificador3,new.usuario,new.correo) 

at time of registering person saving follows in table bitacora

enter image description here

enter image description here

i thought of doing update trigger in bitacora when user data logged , trigger triggered, fill filled same fields being entered person in fields empty on left side have no idea how it. if can me or give me idea how appreciate it

assuming usuarios_cedula foreign key personas.cedula, can in second trigger:

create trigger `usuarios_ainsertar` after insert on `usuarios`  each row      update bitacorapersonas     set usuarionuevo = new.usuario, correonuevo = new.correo     cedula = new.usuarios_cedula 

this add these 2 columns row inserted trigger on personas.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

php - Cannot override Laravel Spark authentication with own implementation -

angular - DownloadURL return null in below code -