0
votes

I have a very simple 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;

And I have a client .Net 4.0 code to consume the SP above

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

When I ran it I got error ERROR [42000] [Microsoft][ODBC driver for Oracle]Syntax error or access violation, the whole call stack is

System.Data.Odbc.OdbcException was unhandled Message=ERROR [42000] [Microsoft][ODBC driver for Oracle]Syntax error or access violation
Source=msorcl32.dll ErrorCode=-2146232009 StackTrace: at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod) at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader) at System.Data.Odbc.OdbcCommand.ExecuteNonQuery() at ConsoleApplication1.Program.Main(String[] args) in D:\Temp\ConsoleApplication1\ConsoleApplication1\Program.cs:line 32 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(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 callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

The error message here is very unclear what is wrong. Anybody has some clue what shall I look into?

1

1 Answers

0
votes

I did some other testing, and simply changed data type from CLOB to varchar2 in SP, and the code works with the limitation that I can send up to 31.75K string size to SP.