SQL 查询时出错:EXECUTE 或 OPEN 语句中主变量的值太大,无法对应使用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8137515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error while Querying : The value of a host variable in the EXECUTE or OPEN statement is too large for its corresponding use
提问by user1002782
On trying to use a select query statement. The input variable has 8 characters just as expected.
在尝试使用选择查询语句时。正如预期的那样,输入变量有 8 个字符。
I dont know why this error comes for select query because for a select query it will query and if its available it will return else it will retun blank rows.
我不知道为什么选择查询会出现此错误,因为对于选择查询,它将查询,如果可用,它将返回,否则它将返回空行。
Hibernate is used. Even in mapping its correctly mapped as 8 only.
使用休眠。即使在映射其正确映射为 8 只。
This is what i found in log file:
这是我在日志文件中发现的:
Cause = com.ibm.db2.jcc.a.SqlException: The value of a host variable in the EXECUTE or OPEN statement is too large for its corresponding use.
Has anybody come across this error before? Please suggest me some solutions on why this error occurs..
有没有人遇到过这个错误?请建议我一些关于为什么会发生此错误的解决方案..
回答by LCJ
One possibility... This issue can come even in SELECT statement. When the parameter passed into the query is more than the size of its datatype's size, this error will pop-up.
一种可能性......这个问题甚至可能出现在 SELECT 语句中。当传入查询的参数大于其数据类型的大小时,将弹出此错误。
Example:
例子:
Datatype - CHAR(12)
Search Param: "123456789012345"