使用 12c 客户端截断的存储过程 OUTPUT VARCHAR2 值 [英] Stored procedure OUTPUT VARCHAR2 value truncated using 12c client
问题描述
我使用的是 oracle 11g.我的存储过程返回 varchar2
但它的值被 oracle 客户端
截断.下面是我的代码:
I am using oracle 11g. My stored procedure is returning varchar2
but its value is being truncated by oracle client
.
Below is my code :
if ((ds != null) && (ds.Tables.Count > 0))
{
foreach (DataRow rw in ds.Tables[0].Rows)
{
OracleParameter param = new OracleParameter((rw["argument_name"]).ToString(), GetOracleType(rw["data_type"].ToString().ToUpper()));
param.Direction = GetParameterDirection((rw["in_out"]).ToString().ToUpper());
discoveryCommand.Parameters.Add(param);
if (param.Direction == ParameterDirection.Output && param.OracleType == OracleType.VarChar)
{
param.Size = 4000;
}
}
}
我将 param.size
增加到 4000
,但值仍然被截断.有没有办法解决这个问题.在服务器上我有 Oracle 12c.我需要在不更新项目中的 oracle 客户端版本的情况下获得解决方案,因为由于某些原因这是不允许的.
I increased the param.size
to 4000
but still values are being truncated.
Is there any solution to this. On server I have Oracle 12c. I need to get solution without updating oracle client version in my project as that is not allowed due to some reasons.
下面是SP.我修改了它以返回硬编码值.还是一样的问题.
Below is the SP . I modified it to return hard-coded values. Still same issue.
PROCEDURE access_level (
p_emp_id IN employees.emp_id%TYPE,
p_id IN NUMBER,
p_type VARCHAR2,
p_access_level OUT VARCHAR2
) IS
BEGIN
p_access_level := 'X' || 'RO' || 'RW';
END IF;
推荐答案
我尝试通过迁移到 ODP.NET
来解决问题,因为 System.Data.OracleClient
正在Microsoft
已弃用 这里,但问题没有解决.以下是问题的解决方法:
I tried to resolve issue by migrating to ODP.NET
as System.Data.OracleClient
is being deprecated by Microsoft
as mentioned here
, but issue was not resolved. Below is how issue was resolved :
- 安装在机器
12.1.0.2.2
上的 Oracle 客户端版本 输出参数截断
错误在Oracle
文档中被提及为Bug21616079
Oracle
已在12.2.0.1.0
版本中修复了Oracle
文档 此处.- 因此从
12.1.0.2.2
升级到版本12.2.0.1.0
为我解决了这个问题,因为Oracle
已在仅在官方Oracle
文档中提到的这个版本,我在上面的第 3 点中提供了链接.
- Oracle client version installed on machine
12.1.0.2.2
Output parameter truncation
bug is mentioned inOracle
docs asBug21616079
Oracle
has given fix in version12.2.0.1.0
as mentioned inOracle
documentation here.- So upgrading to version
12.2.0.1.0
from12.1.0.2.2
fixed this issue for me asOracle
has given fix in this version only which is mentioned in officialOracle
documentation for which I provided link above in point 3.
这篇关于使用 12c 客户端截断的存储过程 OUTPUT VARCHAR2 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!