mysql - Trigger phpMyAdmin using variables -


i trying create trigger in phpmyadmin, can modify value of field whenever inserted depending of field name. using syntax

create trigger lawyers after insert on wp_posts each row begin update wp_posts set post_content = '<!--:en-->&nbsp;<!--:--><!--:es-->&nbsp;<!--:-->'       id = new.id , post_type = 'lawyers'; end 

but can't make work, says:

#1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 4 

can please me?

you can't write such trigger anyway, updating same table you're inserting into. when tested trigger, got this:

error 1442 (hy000): can't update table 'wp_posts' in stored function/trigger because used statement invoked stored  function/trigger. 

the following should same thing trigger:

create trigger lawyers before insert on wp_posts each row begin  if (new.post_type = 'lawyers')   set new.post_content = '<!--:en-->&nbsp;<!--:--><!--:es-->&nbsp;<!--:-->';  end if; end 

answer: phpmyadmin requires special mode if use create trigger or create procedure.

  • below sql query box, there's small form field labeled delimiter. set $$.

  • enter create trigger statement , terminate $$ after last end.

  • click go button.

see http://wiki.phpmyadmin.net/pma/trigger

this analogous using delimiter built-in command in mysql command-line client.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -