简体   繁体   中英

Can I have a variable type as a input parameter for a stored procedure in MySQL?

例如,参数可以是INT类型, FLOATDATETIME等。

You can add something the param as a varchar and then convert it to appropriate type using a CASE structure and then use it in your procedure,of sort:


BEGIN
    DECLARE v VARCHAR DEFAULT "NULL";

    CASE v
      WHEN 'INT' THEN CONVERT(v AS INT);
      WHEN 'FLOAT' THEN CONVERT(v AS FLOAT);
      ELSE
        BEGIN
        END;
    END CASE;
  END;

您的意思是像@Qty int这样的输入参数吗?

每次您必须手动编辑存储功能以更改数据类型时。

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