MySQL Forums
Forum List  »  Triggers

Syntax error in trigger
Posted by: Gabriella Pepe
Date: August 11, 2017 03:37AM

I created this trigger:

BEGIN

DECLARE current_id bigint(20);
DECLARE mail_address varchar(100);
DECLARE user_id bigint(20);

SET current_id = post_id

SET mail_address = (SELECT meta_value FROM wp_postmeta WHERE post_id = current_id AND meta_key = "_from_email")

SET user_id = (SELECT ID FROM wp_users WHERE user_email = mail_address)

IF(exists(
SELECT * FROM wp_posts WHERE ID = current_id AND post_type = "inbound" AND post_title IN ("Website feedback","General contact form")) THEN

UPDATE wp_posts SET author = user_id WHERE ID = current_id

END IF;

END;

but I get this error:

MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your server version for the right syntax to user near 'SET mail_address... at line 9'

Do you spot any error in my syntax?

Any help is appreciated

Options: ReplyQuote


Subject
Views
Written By
Posted
Syntax error in trigger
1743
August 11, 2017 03:37AM
649
August 11, 2017 10:57AM
847
August 12, 2017 02:47AM
647
August 12, 2017 07:49AM
781
August 13, 2017 12:15AM
858
August 13, 2017 12:35AM
795
August 13, 2017 11:09AM
705
August 14, 2017 05:47AM
717
August 14, 2017 10:17AM


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.