简体   繁体   中英

Syntax Procedure Mysql

I'm trying to create a stored procedure in phpmyadmin but when I try to create a second one, I get the error

#1327 - Undeclared variable.

This works fine:

BEGIN
    DECLARE id_pro INT(9);
    SELECT user_product_id INTO id_pro FROM usuario;
END

But if I want to add another variable, I get the error above:

BEGIN
    DECLARE id_pro INT(9);
    DECLARE date_product datetime;
    SELECT user_product_id INTO id_pro, date_pro INTO date_product FROM usuario;
END

It doesn't detect date_product variable.

To assign INTO several variables, use the following syntax:

SELECT user_product_id, date_pro INTO id_pro, date_product FROM usuario;

See the MySQL SELECT ... INTO syntax .

Or don't use INTO :

SELECT id_pro := user_product_id, date_product := date_pro 
FROM usuario;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM