mysql - declaring and using variables in a trigger -
i declaring variables in mysql trigger
delimiter // create trigger lestrigger after insert on examinations each row begin declare the_last_inserted_id int ; declare the_class_id int; declare the_year_id int; set the_last_inserted_id = last_insert_id(); set the_class_id = select examination_class_id examinations examination_id = the_last_inserted_id; set the_year_id = select examination_class_year_id examinations examination_id = the_last_inserted_id; insert examination_data (ed_cs_id,ed_examination_id) select cs_id class_students cs_class_id = the_class_id , cs_year_id = the_year_id,the_last_inserted_id; end // delimiter ;
but keep getting error
/* sql error (1064): have error in sql syntax; check manual corresponds mysql server version right syntax use near 'select examination_class_id examinations examination_id = the_last_in' @ line 10 */
is way using variables syntactically right?.
use into
keyword http://dev.mysql.com/doc/refman/5.0/en/select-into.html
select examination_class_id the_class_id examinations examination_id = the_last_inserted_id; select examination_class_year_id the_year_id examinations examination_id = the_last_inserted_id;
Comments
Post a Comment