Oracle的ODBC驱动程序:语法错误或访问冲突

时间:2012-04-16 13:23:13

标签: c# oracle10g odbc

我有一个非常简单的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] [Oracle ODBC驱动程序]语法错误或访问冲突,整个调用堆栈是

  

System.Data.Odbc.OdbcException未处理Message = ERROR [42000]   [Microsoft] [Oracle的ODBC驱动程序]语法错误或访问冲突
  Source = msorcl32.dll ErrorCode = -2146232009 StackTrace:          在System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle,RetCode retcode)          在System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior   behavior,String方法,Boolean needReader,Object [] methodArguments,   SQL_API odbcApiMethod)          在System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior   行为,String方法,Boolean needReader)          在System.Data.Odbc.OdbcCommand.ExecuteNonQuery()          在D:\ Temp \ ConsoleApplication1 \ ConsoleApplication1 \ Program.cs中的ConsoleApplication1.Program.Main(String [] args):第32行          在System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,String [] args)          在System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)          在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()          在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)          at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean   ignoreSyncCtx)          在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)          在System.Threading.ThreadHelper.ThreadStart()InnerException:

这里的错误信息很不清楚是什么问题。任何人都有一些线索我应该研究什么?

1 个答案:

答案 0 :(得分:0)

我做了一些其他测试,只是简单地将数据类型从CLOB更改为SP中的varchar2,并且代码的工作原理是我可以向SP发送最多31.75K字符串大小。