调用存储过程时出现异常:ORA-01460 - 未实现或请求的转换不合理
我尝试使用 ADO .NET 调用存储过程,但收到以下错误:
ORA-01460 - 未实现或 请求的转换不合理
我尝试调用的存储过程具有以下参数:
param1 IN VARCHAR2,
param2 IN NUMBER,
param3 IN VARCHAR2,
param4 OUT NUMBER,
param5 OUT NUMBER,
param6 OUT NUMBER,
param7 OUT VARCHAR2
下面是我用来调用存储过程的 C# 代码:
OracleCommand command = connection.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "MY_PROC";
OracleParameter param1 = new OracleParameter() { ParameterName = "param1", Direction = ParameterDirection.Input,
Value = p1, OracleDbType = OracleDbType.Varchar2, Size = p1.Length };
OracleParameter param2 = new OracleParameter() { ParameterName = "param2", Direction = ParameterDirection.Input,
Value = p2, OracleDbType = OracleDbType.Decimal };
OracleParameter param3 = new OracleParameter() { ParameterName = "param3", Direction = ParameterDirection.Input,
Value = p3, OracleDbType = OracleDbType.Varchar2, Size = p3.Length };
OracleParameter param4 = new OracleParameter() { ParameterName = "param4", Direction = ParameterDirection.Output,
OracleDbType = OracleDbType.Decimal };
OracleParameter param5 = new OracleParameter() { ParameterName = "param5", Direction = ParameterDirection.Output,
OracleDbType = OracleDbType.Decimal};
OracleParameter param6 = new OracleParameter() { ParameterName = "param6", Direction = ParameterDirection.Output,
OracleDbType = OracleDbType.Decimal };
OracleParameter param7 = new OracleParameter() { ParameterName = "param7", Direction = ParameterDirection.Output,
OracleDbType = OracleDbType.Varchar2, Size = 32767 };
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
command.Parameters.Add(param5);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
command.ExecuteNonQuery();
有什么想法我做错了吗?
I'm trying to call a stored procedure using ADO .NET and I'm getting the following error:
ORA-01460 - unimplemented or
unreasonable conversion requested
The stored procedure I'm trying to call has the following parameters:
param1 IN VARCHAR2,
param2 IN NUMBER,
param3 IN VARCHAR2,
param4 OUT NUMBER,
param5 OUT NUMBER,
param6 OUT NUMBER,
param7 OUT VARCHAR2
Below is the C# code I'm using to call the stored procedure:
OracleCommand command = connection.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "MY_PROC";
OracleParameter param1 = new OracleParameter() { ParameterName = "param1", Direction = ParameterDirection.Input,
Value = p1, OracleDbType = OracleDbType.Varchar2, Size = p1.Length };
OracleParameter param2 = new OracleParameter() { ParameterName = "param2", Direction = ParameterDirection.Input,
Value = p2, OracleDbType = OracleDbType.Decimal };
OracleParameter param3 = new OracleParameter() { ParameterName = "param3", Direction = ParameterDirection.Input,
Value = p3, OracleDbType = OracleDbType.Varchar2, Size = p3.Length };
OracleParameter param4 = new OracleParameter() { ParameterName = "param4", Direction = ParameterDirection.Output,
OracleDbType = OracleDbType.Decimal };
OracleParameter param5 = new OracleParameter() { ParameterName = "param5", Direction = ParameterDirection.Output,
OracleDbType = OracleDbType.Decimal};
OracleParameter param6 = new OracleParameter() { ParameterName = "param6", Direction = ParameterDirection.Output,
OracleDbType = OracleDbType.Decimal };
OracleParameter param7 = new OracleParameter() { ParameterName = "param7", Direction = ParameterDirection.Output,
OracleDbType = OracleDbType.Varchar2, Size = 32767 };
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
command.Parameters.Add(param5);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
command.ExecuteNonQuery();
Any ideas what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不确定它是否相关,但 SQL VARCHAR2 值限制为 4000(尽管 PL/SQL 可以处理 32000)
您可以尝试将“Size = 32767”修改为较小的值(例如 500),看看是否有效。
另请检查您传入的字符串的大小。如果其中一个字符串有 50000 个字符,则可能是问题所在。
Not sure if it is relevant but SQL VARCHAR2 values are limited to 4000 (though PL/SQL can cope with 32 thousand)
You could try amending "Size = 32767" to something smaller (eg 500) and see if that works.
Also look into the sizes of the strings you are passing in. If one of them is 50000 characters, that might be the problem.
你用的是什么oracle客户端。有一个与绑定相关的 Oracle 问题,它给出了相同的错误消息。如果我没记错的话,问题是从 10.2.0.3 到 11.1.0.7 的所有客户端都会出现此错误。
我有一个应用程序在 10.2.0.1 上运行良好,但突然在 11.1.0.7 客户端上出现了上述错误。
切换到 11.2.0.1 oracle 客户端解决了该问题。
但是,在您的情况下,我会首先检查您客户端的 NLS 设置是否与数据库匹配(或至少兼容)。
不能保证这是相同的问题,但您至少可以仔细检查它。
//抱歉,刚刚看到它已经修复,但该信息有时可能对其他人有用
干杯,
克罗克德
what oracle client are you using. There is an oracle issue relating to binds which gives this same error message. If i remember correctly the issue is with all clients from 10.2.0.3 to to 11.1.0.7 that can give this error.
I had an application that worked fine with 10.2.0.1 and suddenly with 11.1.0.7 client it got the above error.
Switching to 11.2.0.1 oracle client fixed the issue.
However in your case I would first check do the NLS settings of your client match the database (or are at least compatible)
Theres no guarantee it's the same issue but you can double check it at least.
//Sorry just saw it's already fixed but the info may be useful to someone else sometime
Cheers,
Crocked
您将值推入参数的哪里?
编辑:抱歉,问得不好。相反,您推入参数的值来自哪些? ADO.NET 实现不会检查您推入客户端参数的对象的类型;服务器负责验证对象类型是否与您指定的数据库参数类型相符。转换错误可能是由于将参数声明为 OracleDbType.Decimal,然后意外地将字符串推入其中而导致的。
Where are you pushing the values into the parameters?
Edit: Sorry, bad question. Rather, what are the values you're pushing into the parameters coming from? The ADO.NET implementation doesn't check the type of the object you push into the parameter on the client side; the server is responsible for verifying that the object type meshes with the DB parameter type you've given it. The conversion error can be caused by declaring a parameter as, say, OracleDbType.Decimal and then pushing a string into it by accident.