O que há de errado com esta trigger ?
DELIMITER ;
CREATE TRIGGER Update_Status AFTER UPDATE ON sales_order
FOR EACH ROW
BEGIN
IF OLD.status <> NEW.status AND (NEW.status = 20 OR NEW.status = 27 OR NEW.status = 30) THEN
INSERT INTO order_status(orders,current_status,momento_captura,check_link)VALUES(NEW.partner_order_id,NEW.status,(SELECT CONCAT(DATE(NOW()),' ',TIME(NOW()))),(SELECT content_url FROM book b INNER JOIN sales_order_item soi ON b.id = soi.book_id INNER JOIN sales_order so ON soi.order_id = so.id WHERE so.id = NEW.id));
INSERT INTO order_status(orders,current_status,momento_captura,check_link)VALUES(NEW.partner_order_id,NEW.status,(SELECT CONCAT(DATE(NOW()),' ',TIME(NOW()))),(SELECT cover_url FROM book b INNER JOIN sales_order_item soi ON b.id = soi.book_id INNER JOIN sales_order so ON soi.order_id = so.id WHERE so.id = NEW.id));
END IF;
END;
Quando eu a executo recebo o erro:
Erro
consulta SQL: Documentação
DELIMITER;
CREATE TRIGGER Update_Status AFTER UPDATE ON sales_order FOR EACH ROW BEGIN IF OLD.status <> NEW.status AND (
NEW.status =20 OR NEW.status =27 OR NEW.status =30
) THEN INSERT INTO order_status( orders, current_status, momento_captura, check_link )
VALUES (
NEW.partner_order_id, NEW.status, (
SELECT CONCAT( DATE( NOW( ) ) , ' ', TIME( NOW( ) ) )
), (
SELECT content_url
FROM book b
INNER JOIN sales_order_item soi ON b.id = soi.book_id
INNER JOIN sales_order so ON soi.order_id = so.id
WHERE so.id = NEW.id
)
);
Mensagens do MySQL : Documentação
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7
Pergunta
Renato Penna
O que há de errado com esta trigger ? DELIMITER ; CREATE TRIGGER Update_Status AFTER UPDATE ON sales_order FOR EACH ROW BEGIN IF OLD.status <> NEW.status AND (NEW.status = 20 OR NEW.status = 27 OR NEW.status = 30) THEN INSERT INTO order_status(orders,current_status,momento_captura,check_link)VALUES(NEW.partner_order_id,NEW.status,(SELECT CONCAT(DATE(NOW()),' ',TIME(NOW()))),(SELECT content_url FROM book b INNER JOIN sales_order_item soi ON b.id = soi.book_id INNER JOIN sales_order so ON soi.order_id = so.id WHERE so.id = NEW.id)); INSERT INTO order_status(orders,current_status,momento_captura,check_link)VALUES(NEW.partner_order_id,NEW.status,(SELECT CONCAT(DATE(NOW()),' ',TIME(NOW()))),(SELECT cover_url FROM book b INNER JOIN sales_order_item soi ON b.id = soi.book_id INNER JOIN sales_order so ON soi.order_id = so.id WHERE so.id = NEW.id)); END IF; END; Quando eu a executo recebo o erro: Erro consulta SQL: Documentação DELIMITER; CREATE TRIGGER Update_Status AFTER UPDATE ON sales_order FOR EACH ROW BEGIN IF OLD.status <> NEW.status AND ( NEW.status =20 OR NEW.status =27 OR NEW.status =30 ) THEN INSERT INTO order_status( orders, current_status, momento_captura, check_link ) VALUES ( NEW.partner_order_id, NEW.status, ( SELECT CONCAT( DATE( NOW( ) ) , ' ', TIME( NOW( ) ) ) ), ( SELECT content_url FROM book b INNER JOIN sales_order_item soi ON b.id = soi.book_id INNER JOIN sales_order so ON soi.order_id = so.id WHERE so.id = NEW.id ) ); Mensagens do MySQL : Documentação #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.