Mysql database එකක එක table එකක column එකක value එක අනුව තව table එකක column එකක value එකක් automatically update වෙන්න හදන්නේ කොහොමද. Trigger එක කලා ඒත් error එකක් එනවා. Syntax error
SQL QUERY FOR TRIGGER
-----------------------------
Error
-----
SQL query:
CREATE TRIGGER update_winner_trigger AFTER UPDATE ON oc_t_item_meta
FOR EACH ROW
BEGIN
-- Get the current timestamp
DECLARE current_timestamp INT
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'current_timestamp INT' at line 5
SQL QUERY FOR TRIGGER
-----------------------------
CREATE TRIGGER update_winner_trigger AFTER UPDATE ON oc_t_item_meta FOR EACH ROW BEGIN -- Get the current timestamp DECLARE current_timestamp INT; SET current_timestamp = UNIX_TIMESTAMP(); -- Update winner based on the specified conditions UPDATE oc_t_auction AS a JOIN oc_t_item AS i ON a.item_id = i.pk_i_id JOIN oc_t_item_meta AS m1 ON i.pk_i_id = m1.fk_i_item_id JOIN oc_t_item_meta AS m2 ON i.pk_i_id = m2.fk_i_item_id SET a.winner = CASE WHEN m1.fk_i_field_id = 16 AND m1.s_value > current_timestamp AND (m2.fk_i_field_id = 15 AND m2.s_value >= a.bidding_price) THEN 1 WHEN m1.fk_i_field_id != 16 AND i.dt_expiration > current_timestamp AND (m2.fk_i_field_id = 15 AND m2.s_value >= a.bidding_price) THEN 1 ELSE 0 END WHERE a.item_id = NEW.fk_i_item_id; END;
Error
-----
SQL query:
CREATE TRIGGER update_winner_trigger AFTER UPDATE ON oc_t_item_meta
FOR EACH ROW
BEGIN
-- Get the current timestamp
DECLARE current_timestamp INT
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'current_timestamp INT' at line 5
Last edited: