简体   繁体   English

存储过程参数类型

[英]Stored Procedure Parameter Type

I have a question about the in parameter type of a stored procedure. 我有一个关于存储过程的in参数类型的问题。 Normally the definition of a parameter will look like this: 通常,参数的定义如下所示:

in param_test VARCHAR(100)

Do you know if I can defined a parameter like this?: 你知道我是否可以定义这样的参数吗?:

in param_test table.column%type

This way the parameter will be the same type as the column of an specific table. 这样,参数将与特定表的列类型相同。 So if the column type change from varchar(100) to varchar(250) I don't have to change the parameter type in the stored procedure. 因此,如果列类型从varchar(100)更改为varchar(250),则不必更改存储过程中的参数类型。

I know It's possible in Oracle, but I don't know if it is in MySQL. 我知道在甲骨文中这是可能的,但我不知道它是否在MySQL中。

Thank you very much for your time and help. 非常感谢您的时间和帮助。

Regards. 问候。

That syntax is not supported in MySQL. MySQL不支持该语法。 You need to explicitly declare the datatype for a parameter in a stored program. 您需要在存储的程序中显式声明参数的数据类型。

If you want to protect yourself from future changes to the max length of a varchar column, you can just use the TEXT datatype for the parameter, 如果您希望保护自己免受将来varchar列最大长度的更改,可以使用TEXT数据类型作为参数,

how to pass parameter value to database of text datatype.. i am using this code mysql_CommandLtp.Parameters.Add("@prmName", MySqlDbType.Text); 如何将参数值传递给text数据类型的数据库..我正在使用此代码mysql_CommandLtp.Parameters.Add(“@ prmName”,MySqlDbType.Text); mysql_CommandLtp.Parameters["@prmName"].Value = prmName.ToString().Trim(); mysql_CommandLtp.Parameters [“@ prmName”]。Value = prmName.ToString()。Trim();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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