When I run a stored-procedure ranking_long() by mentioning call ranking_long() in a stored-procedure, the result is as follows.
product_id plg_count rank
11 6962271 1
10 2705517 2
379 1955067 3
378 196865 4
...........
Now I need to upsert(update when there is the same product_id or insert when there is not the same product_id) the result above into the table called dtb_ranking that has the same structure with the above result (product_id, plg_count, rank) by using a stored-procedure. So I tried the stored-procedure below,
INSERT INTO dtb_ranking (`product_id`,`plg_count`,`rank`) VALUES (CALL `ranking_long`()) ON DUPLICATE KEY UPDATE plg_count = VALUES(plg_count), rank = VALUES(rank);
And I had an error message like below.
One or more errors have occurred while processing your request: Failed to execute a query.:
CREATE DEFINER=xxxxxxx@% PROCEDURE call_ranking_long()
NOT DETERMINISTIC
NO SQL
SQL SECURITY DEFINER
INSERT INTO dtb_ranking
(product_id,plg_count,rank)
VALUES (CALL ranking_long())
ON DUPLICATE KEY UPDATE plg_count = VALUES(plg_count), rank = VALUES(rank);
MySQL's message: #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 'CALL ranking_long()) ON DUPLICATE KEY UPDATE plg_count = VALUES(plg_count), ra' at line 1
I would appreciate if anyone could tell me what I should do with the script above(INSERT INTO dtb_ranking...).