MySQL Forums
Forum List  »  Triggers

Re: MySQL said: Documentation #1362 - Updating of NEW row is not allowed in after trigger "
Posted by: Damien Morley
Date: August 22, 2011 08:23AM

OK i think i have gotten a little further, but now im stumped again...

I have chenged to BEFORE INSERT and now im getting a little further before it falls over.

Originally i ommited the string values just to keep everything a little more tidy but here is the actual statement im making.

Basically i want to change any string that equals the first to the second.



DELIMITER $$
DROP TRIGGER IF EXISTS setMetaValue $$

CREATE TRIGGER setMetaValue BEFORE INSERT ON wp_postmeta
FOR EACH ROW
BEGINĀ 
IF NEW.meta_value = 'O:8:"mgm_post":8:{s:11:"purchasable";s:1:"N";s:13:"purchase_cost";s:1:"0";s:15:"purchase_expiry";s:0:"";s:17:"purchase_duration";s:1:"0";s:7:"product";a:0:{}s:23:"access_membership_types";a:0:{}s:12:"access_delay";a:0:{}s:15:"access_duration";s:1:"0";}' THEN

SET NEW.meta_value = 'O:8:"mgm_post":8:{s:11:"purchasable";s:1:"N";s:13:"purchase_cost";s:1:"4";s:15:"purchase_expiry";s:0:"";s:17:"purchase_duration";s:1:"0";s:7:"product";a:0:{}s:23:"access_membership_types";a:1:{i:0;s:6:"member";}s:12:"access_delay";a:4:{s:5:"guest";s:1:"0";s:5:"trial";s:1:"0";s:4:"free";s:1:"0";s:6:"member";s:1:"0";}s:15:"access_duration";s:1:"0";}';

END IF;
END $$

DELIMITER ;


It seems to me that the string values are being read as syntax and everything falls over. How can i write this so the syntax characters are not executed?



Edited 1 time(s). Last edit at 08/22/2011 08:56AM by Damien Morley.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: MySQL said: Documentation #1362 - Updating of NEW row is not allowed in after trigger "
2935
August 22, 2011 08:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.