2012-04-16 143 views
-1

我有一個非常簡單的Oracle SPOracle ODBC驅動程序:語法錯誤或訪問衝突

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代碼來使用上述

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); 
    } 
} 

的SP當我運行它我得到錯誤錯誤[42000] [Microsoft] [用於Oracle的ODBC驅動程序]語法錯誤或訪問衝突,整個調用堆棧爲

System.Data.Odbc.OdbcException was unhandled Message = ERROR [42000] [Microsoft] [用於Oracle的ODBC驅動程序]語法錯誤或訪問衝突
Source = msorcl32.dll ErrorCode = -2146232009 StackTrace: at System.Data .Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle,RETCODE RETCODE) 在System.Data.Odbc.OdbcCommand.ExecuteReaderObject(的CommandBehavior 行爲,字符串方法,布爾needReader,對象[] methodArguments, SQL_API odbcApiMethod) 在System.Data。 Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior,String method,Boolean needReader) at System.Data.Odbc.OdbcCommand.ExecuteNonQuery() at Conso d:\ Temp \ ConsoleApplication1 \ ConsoleApplication1 \ Program.cs中的leApplication1.Program.Main(String [] args):位於System.AppDomain.ExecuteAssembly的System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,String [] args) 處的第32行 (String assemblyFile,Evidence assemblySecurity,String [] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext ,ContextCallback回調,對象狀態,布爾 ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state) at System.Threading.ThreadHelper.ThreadStart()I nnerException:

這裏的錯誤信息很不清楚什麼是錯的。任何人都有一些線索,我該看什麼?

回答

0

我做了一些其他測試,並簡單地將CLOB中的數據類型更改爲SP中的varchar2,並且該代碼適用於可以將高達31.75K字符串大小發送給SP的限制。

相關問題