MySQL Forums
Forum List  »  Spanish

Re: Problema con Trigger
Posted by: Peter Brawley
Date: January 28, 2022 11:21PM

Nuevamente, ¿cuál es la razón para crear esta redundancia?

No ha mostrado DDL para la tabla `articulos`. Infiriendo su estructura a partir de tu Trigger, tengo...

drop table if exists articulos, links;

create table articulos (
  codinterno int primary key,
  codigo varchar(20) character set latin1 default null,
  descripcion varchar(60) character set latin1 default null,
  master varchar(20) character set latin1 default null
);

create trigger `articulos_graba_links` after insert on `articulos` for each row 
  insert into links(codinterno,codigob,descripcion,master) 
  values(new.codinterno,new.codigo,new.descripcion,new.codigo);

create table `links` (
`id` int not null auto_increment,
`codinterno` int default null,
`codigob` varchar(20) character set latin1 default null,
`descripcion` varchar(60) character set latin1 default null,
`master` varchar(20) character set latin1 default null,
primary key (`id`),
unique key `porcodigob` (`codigob`),
key `porcodinterno` (`codinterno`),
key `pormaster` (`master`)
) engine=innodb auto_increment=6105 default charset=latin1 collate=latin1_bin;

insert into articulos values
  (1,'abc','abc','abc'), (2,'def','def','def');

select * from links;
+------+------------+---------+-------------+--------+
| id   | codinterno | codigob | descripcion | master |
+------+------------+---------+-------------+--------+
| 6105 |          1 | abc     | abc         | abc    |
| 6106 |          2 | def     | def         | def    |
+------+------------+---------+-------------+--------+



Edited 1 time(s). Last edit at 01/29/2022 09:34AM by Peter Brawley.

Options: ReplyQuote


Subject
Views
Written By
Posted
811
January 27, 2022 09:40PM
208
January 27, 2022 11:21PM
219
January 28, 2022 06:52PM
Re: Problema con Trigger
229
January 28, 2022 11:21PM


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.