MySQL Forums
Forum List  »  Stored Procedures

1287 Setting user variables within expressions is deprecated and will be removed in a future release
Posted by: Michael Zatkovetsky
Date: October 19, 2022 11:57AM

Hi! We use this technique to update ranking columns
SET category_rank = (SELECT @i := @i + 1)

Now we've been getting lots of these warnings:
1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression,

How can I change the technique to avoid the warning?

CREATE TABLE `categories` (
`client_id` int NOT NULL,
`category_id` int NOT NULL DEFAULT '0',
`category_rank` int DEFAULT NULL,
`index_low` int DEFAULT NULL,
`index_high` int DEFAULT NULL,
`category_color` varchar(45) DEFAULT NULL,
`category_name` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

INSERT INTO categories(client_id, category_id, category_rank, index_low, index_high, category_color, category_name) VALUES
(100, 36, NULL, 0, 44, '#006830', 'A'),
(100, 37, NULL, 45, 110, '#FBB022', 'B'),
(100, 38, NULL, 111, 222, '#F15800', 'C'),
(100, 39, NULL, 223, 400, '#FE8011', 'D'),
(104, 1, NULL, 0, 50, '#47AB5B', 'E'),
(104, 2, NULL, 51, 100, '#47A1CB', 'F'),
(104, 3, NULL, 101, 200, '#475FCB', 'G'),
(104, 4, NULL, 201, 400, '#7147CB', 'H'),
(144, 21, NULL, 300, 6000, '#47AB5B', 'I'),
(158, 15, NULL, 59, 99, '#330000', 'J'),
(158, 23, NULL, 0, 11, NULL, 'K'),
(162, 16, NULL, 0, 50, '#47AB5B', 'L'),
(162, 17, NULL, 51, 100, '#47A1CB', 'M'),
(162, 18, NULL, 101, 200, '#475FCB', 'N'),
(162, 19, NULL, 201, 400, '#7147CB', 'O'),
(192, 40, NULL, 0, 44, '#006830', 'P'),
(192, 41, NULL, 45, 110, '#FBB022', 'Q'),
(192, 42, NULL, 111, 222, '#F15800', 'R');

Many thanks in advance

Options: ReplyQuote


Subject
Views
Written By
Posted
1287 Setting user variables within expressions is deprecated and will be removed in a future release
688
October 19, 2022 11:57AM


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.