mysql - error in trigger creation also how to optimise it -


please tell me whats wrong code. not able fine bug

delimiter $$ create trigger update_status  before update on listing_basic_new_updated  each row  if new.processing_status not null      begin     set new.rep_status = new.processing_status;     end;    elseif new.televeri_status not null      begin     set new.rep_status = new.televeri_status;     end;    elseif new.verification_status not null      begin     set new.rep_status = new.verification_status;     end; end if; end$$ delimiter ; 

i think you're missing begin match end @ end:

delimiter $$ create trigger update_status  before update on listing_basic_new_updated  each row begin  if new.processing_status not null      begin     set new.rep_status = new.processing_status;     end;    elseif new.televeri_status not null      begin     set new.rep_status = new.televeri_status;     end;    elseif new.verification_status not null      begin     set new.rep_status = new.verification_status;     end; end if; end$$ delimiter ; 

i think might able replace of with

set new.rep_status = coalesce(new.processing_status, new.televeri_status,                            new.verification_status, new.rep_status); 

coalesce: "returns first non-null value in list, or null if there no non-null values."


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -