oracle 调用存储过程时出现异常:ORA-01460 - 请求未实现或不合理的转换
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2549259/
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
Exception when calling stored procedure: ORA-01460 - unimplemented or unreasonable conversion requested
提问by Taylor Leese
I'm trying to call a stored procedure using ADO .NET and I'm getting the following error:
我正在尝试使用 ADO .NET 调用存储过程,但出现以下错误:
ORA-01460 - unimplemented or unreasonable conversion requested
ORA-01460 - 请求的转换未实现或不合理
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:
下面是我用来调用存储过程的 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();
Any ideas what I'm doing wrong?
任何想法我做错了什么?
回答by Gary Myers
Not sure if it is relevant but SQL VARCHAR2 values are limited to 4000 (though PL/SQL can cope with 32 thousand)
不确定它是否相关,但 SQL VARCHAR2 值限制为 4000(尽管 PL/SQL 可以处理 32000)
You could try amending "Size = 32767" to something smaller (eg 500) and see if that works.
您可以尝试将“Size = 32767”修改为更小的值(例如 500),看看是否有效。
Also look into the sizes of the strings you are passing in. If one of them is 50000 characters, that might be the problem.
还要查看您传入的字符串的大小。如果其中一个是 50000 个字符,那可能就是问题所在。
回答by Crocked
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.
您使用的是什么 oracle 客户端。有一个与绑定相关的 oracle 问题,它给出了同样的错误消息。如果我没记错的话,问题是从 10.2.0.3 到 11.1.0.7 的所有客户端都会出现此错误。
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.
我有一个在 10.2.0.1 上运行良好的应用程序,突然在 11.1.0.7 客户端上出现了上述错误。
Switching to 11.2.0.1 oracle client fixed the issue.
切换到 11.2.0.1 oracle 客户端修复了该问题。
However in your case I would first check do the NLS settings of your client match the database (or are at least compatible)
但是,在您的情况下,我会首先检查您的客户端的 NLS 设置是否与数据库匹配(或至少兼容)
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
干杯,破碎
回答by Dan Story
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.
编辑:对不起,不好的问题。相反,您推入参数的值是什么?ADO.NET 实现不会检查您推送到客户端参数中的对象的类型;服务器负责验证对象类型是否与您提供的 DB 参数类型相匹配。转换错误可能是由于将参数声明为 OracleDbType.Decimal,然后意外地将字符串推入其中造成的。