I’m creating a stored procedure in memsql and specifically trying to declare a QUERY type variable in the BEGIN section of the procedure_body of the procedure. The CREATE PROCEDURE doc (SingleStoreDB Cloud · SingleStore Documentation) says I should be able to assign a query variable within the procedure body.
It explicitly states “SELECT statements may be used if assigned to a query type variable”, however I receive a sql syntax error when trying to assign a query variable to a select statement within the BEGIN and END of the procedure_body. I can assign the query just fine in the DECLARE section.
A code example:
DELIMITER //
create procedure foo(b int ) AS
DECLARE
a query(x int ) = select 1;
BEGIN
END //
DELIMITER ; ← This code passes
DELIMITER //
create procedure foo(b int ) AS
BEGIN
a query(x int ) = select 1;
END //
DELIMITER ; <— This code fails