Triggers PhpMyAdmin

0

I have the following trigger:

CREATE OR REPLACE TRIGGER tr_insercion_evento 
AFTER INSERT ON evento
BEGIN
INSERT INTO historico_evento(historico_evento.id, historico_evento.fecha_cambio, historico_evento.evento_id, historico_evento.usuario_exowner)
VALUES(NULL, sysdate, :NEW.id, :NEW.usuario_owner)
END tr_insercion_evento;//

In PhpMyAdmin I indicated that the delimiter is "//" (I also tried to do it from the same sentence with "DELIMITER //", but there is no case:

#1064 - Algo está equivocado en su sintax cerca 'TRIGGER tr_insercion_evento 
AFTER INSERT ON evento
BEGIN
INSERT ' en la linea 1

Event table

id (int pk), title (text), start (date), end (date), user_owner (int fk-> user)

Historical_table

id (int pk), date_change (date), event_id (int fk-> event), user_exowner (int)

User table

id (int pk), name (text)

Note: Just in case, I clarify that the restrictions I gave to the fk are cascaded (update and delete).

What am I doing wrong? From what I have read in forums and right here, many of us have problems with phpmyadmin. In Workbench I could do it, but I would like to know how to solve this problem from phpmyadmin itself. Thank you very much.

    
asked by Faju 08.11.2017 в 15:55
source

1 answer

1

The problem is not the delimiter. The (main) problem is that you are using the Oracle syntax to define the trigger, not the MySQL syntax ( OR REPLACE , :NEW , sysdate without parentheses, etc.).

In MySQL the trigger would be:

CREATE TRIGGER tr_insercion_evento 
AFTER INSERT ON evento FOR EACH ROW
BEGIN
  INSERT INTO historico_evento(id, fecha_cambio, evento_id, usuario_exowner)
  VALUES(NULL, sysdate(), NEW.id, NEW.usuario_owner);
END;//

And if necessary, you add the DELIMITER statements before and after the trigger definition.

    
answered by 08.11.2017 / 16:05
source