Creation of stored procedures in SingleStore fails with [42000][1064] error - Stack Overflow

admin2025-04-18  1

I have a Singlestore instance running in a docker container and I want to create a stored procedure. What I have is: there are many-many rows a part of which have a null value in a column. So let's say all the rows are 10.000 and 2.000 of them have null value in a column.

I want to update the null value with a 0 value so I try the following procedure:

DELIMITER $$
CREATE PROCEDURE update_null_values()
BEGIN
DECLARE rows_updated INT DEFAULT 1;
WHILE (rows_updated > 0) DO
        UPDATE tables_name
        SET column_name = 0
        WHERE column_name IS NULL
        LIMIT 1000000;
        SET rows_updated = ROW_COUNT();
END WHILE;
END $$
DELIMITER ;

I always get the same error:

[42000][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 'BEGIN DECLARE rows_updated INT DEFAULT 1; WHILE (rows_updated > 0) DO ' at line 1

I don't understand what the problem is. I followed the documentation.

Any idea on this ?

转载请注明原文地址:http://anycun.com/QandA/1744909390a89338.html