mysql - UPDATE Same Row After UPDATE in Trigger -


i want epc column earnings/clicks. using after update trigger accomplish this. if add 100 clicks table, want epc update automatically.

i trying this:

create trigger `records_integrity` after update on `records` each row set  new.epc=ifnull(earnings/clicks,0); 

and getting error:

mysql said: #1362 - updating of new row not allowed in after trigger 

i tried using old got error. before if added 100 clicks use previous # clicks trigger (right?)

what should accomplish this?

edit - example of query run on this:

update records set clicks=clicks+100 //epc should update automatically 

you can't update rows in table in after update trigger.

perhaps want this:

create trigger `records_integrity` before update on `records` each row     set new.epc=ifnull(new.earnings/new.clicks, 0); 

edit:

inside trigger, have have access old , new. old old values in record , new new values. in before trigger, new values written table, can modify them. in after trigger, new values have been written, cannot modified. think mysql documentation explains pretty well.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -