MySQL/MariaDB TRIGGER -


i error when try create below trigger on mysql/mariadb

create trigger `abc` before insert on `table1` each row begin declare lcl_var integer; set lcl_lcl_var = new.a - new.b; set new.d= v;    end; 

error

create trigger q_dur_calc before insert on task_q_swh each row begin declare lcl_q_dur integer;

mysql said: documentation

1064 - have error in sql syntax; check manual corresponds mariadb server version right syntax use near '' @ line 3

i've got couple other triggers used build one. can't figure out wrong syntactically this. can please request spot problem this?

when write trigger must specify delimiter mysql explicitly executes trigger block within specified delimiter. if delimiter not provided when encounters ; within trigger statement try execute command till block , hence may errors.

if using user interface tools generating trigger may check if there option set delimiter in phpmyadmin.

in cli trigger needs having delimiter , becomes

delimiter //  create trigger q_dur_calc before insert on task_q_swh each row begin  declare lcl_q_dur integer;  set lcl_q_dur = new.tq_task_dur - new.tq_task_run_dur;  set new.tq_q_dur = lcl_q_dur;    end;//  delimiter ; 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -