1
I’m trying to create a Trigger to update a value after inserting, or earlier if it worked.
I have the following table: test
Remembering that the field type date is timestamp
and the default value is CURRENT_TIMESTAMP
id | date | dado | dado2
1 | 2018-10-22 14:43:32 | Dado 1 |
2 | 2018-10-22 14:44:40 | Dado 2 |
3 | 2018-10-22 14:44:41 | Dado 3 |
4 | 2018-10-22 14:45:41 | Dado 4 |
If I do Trigger using before insert
, when using the field new.date
the value is null.
CREATE TRIGGER `teste_before_insert` BEFORE INSERT ON `teste` FOR EACH ROW BEGIN
insert into debug_table (condicao, condicao2) VALUES (new.date, new.id);
END
This table debug_table was that I created to know if the value is coming, it inserts, but with null data
But if I use after insert
, the field comes filled. Only I would like to update the field dado 2
.
So since the value works with the after insert
, i would like to update the same table with this Trigger in the field dado 2
But it seems that the update does not work
I don’t quite understand, you insert it into the table and want what after?
– novic