Step1: Create query as a string. Step2: Prepare a statement Step3: Execute the statement Step4: Deallocate Prepare statement. Example: #Step1 declare str text; select concat("update tbl_test set datetime=now()") into str; if(condition1=1)then select concat(str,",data='condition1'") into str; elseif(condition2=1)then select concat(str,",data='condition2'") into str; end if; #Step2 set @strVar=str; prepare statement from @strVar; #Step3 execute statement; #Step4 deallocate prepare statement;
|
My Blog Title
|