我有一个非常简单的 Oracle SP
CREATE OR REPLACE procedure DEV.SL_CLOB_TEST(numId IN PLS_INTEGER,id IN PLS_INTEGER, strText IN CLOB)
as
begin
insert into test_table values (numId,id, strText, sysdate, user);
end;
我有一个客户端 .Net 4.0 代码来使用上面的 SP
static void Main(string[] args)
{
string connectionString = "Driver={Microsoft ODBC for Oracle};Server=server;Uid=username;Pwd=password";
var connection = new OdbcConnection(connectionString);
connection.Open();
IDbCommand command = connection.CreateCommand();
command.CommandText = "{call SL_CLOB_TEST(?,?,?)}";
command.CommandType = CommandType.StoredProcedure;
OdbcParameter parameter1 = new OdbcParameter("NUMID", OdbcType.Int);
parameter1.Value = 123;
parameter1.Direction = ParameterDirection.Input;
command.Parameters.Add(parameter1);
OdbcParameter parameter2 = new OdbcParameter("ID", OdbcType.Int);
parameter2.Value = 234;
parameter2.Direction = ParameterDirection.Input;
command.Parameters.Add(parameter2);
OdbcParameter parameter3 = new OdbcParameter("STRTEXT", OdbcType.VarChar);
parameter3.Value = getClob();
parameter3.Direction = ParameterDirection.Input;
command.Parameters.Add(parameter3);
command.ExecuteNonQuery();
}
private static string getClob()
{
return new string('a', 10);
}
}
当我运行它时出现错误ERROR [42000] [Microsoft][ODBC driver for Oracle]Syntax error or access violation,整个调用堆栈是
System.Data.Odbc.OdbcException 未处理 Message=ERROR [42000] [Microsoft][ODBC driver for Oracle]语法错误或访问冲突
Source=msorcl32.dll ErrorCode=-2146232009 StackTrace:在 System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle,RetCode retcode)在 System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior 行为,字符串方法,布尔需要阅读器,对象 [ ] methodArguments, SQL_API odbcApiMethod) 在 System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior 行为, 字符串方法, Boolean needReader) 在 System.Data.Odbc.OdbcCommand.ExecuteNonQuery() 在 ConsoleApplication1.Program.Main(String[] args)在 D:\Temp\ConsoleApplication1\ConsoleApplication1\Program.cs:第 32 行 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity,String[] args) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在 System.Threading.ThreadHelper.ThreadStart_Context(Object state) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 在 System.Threading.ThreadHelper.ThreadStart() InnerException:在 System.Threading.ThreadHelper.ThreadStart() InnerException 处运行(ExecutionContext executionContext,ContextCallback 回调,对象状态):在 System.Threading.ThreadHelper.ThreadStart() InnerException 处运行(ExecutionContext executionContext,ContextCallback 回调,对象状态):
这里的错误信息很不清楚是什么问题。有人知道我应该调查什么吗?