Using a trigger on table in mysql -


i creating trigger on table below,

  create table test( id int auto_increment primary key,               name varchar(40),               debit decimal(19,2) default "0.00",               fee decimal(19,2) default "0.00",               balance decimal(19,2) default "0.00")               engine=innodb; 

below trigger code.

create trigger update_test before insert on test t each row (select debit test d d.id="1")   set new.balance=30 + d.debit; 

this trigger suppose update test table(balance column) upon insertion test table.the trigger suppose select debit value test table , add 30 before updating balance column in test table.but query above wouldn't work.it keeps giving me error

error 1415 (0a000): not allowed return result set trigger 

please need on how figure problem is.thanks in advance.

this work.

create trigger update_test before insert on test each row set @d=(select debit test id="1"),   new.balance= 30 + coalesce(@d,0); 

the above code work,try , tell me responds.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -