Search code examples
c#oracle-databaseclob

How to send CLOB parameter from C# to Oracle stored procedure?


I'm new here. I have a problem. I want to execute this code in C#:

string XMLData = File.ReadAllText(App.FolderImport + "\\" + FileName);

Command.CommandType = CommandType.StoredProcedure;
Command.CommandText = "PKG_DATA_EXCHANGE.IMPORT_DATA";
Command.Parameters.Add("pID_USER_M", OracleType.Number).Value = App.User.IdUser;
Command.Parameters.Add("pFILE_NAME", OracleType.VarChar).Value = FileName;
Command.Parameters.Add("pXMLDATA", OracleType.Clob).Value = XMLDataString;

Command.ExecuteNonQuery();

It works fine for small XMLDataString, but if it is bigger then I get exception ORA-01460.

I understand that it is linked somehow to CLOB problem, but I don't know how to solve it.

I was searching for such problem here, but I had no luck.

Please any help, links or code will be very appreciated!


Solution

  • There are other reported causes of the ORA-01460 as well:

    • Incompatible character sets can cause an ORA-01460
    • Using SQL Developer, attempting to pass a string to a bind variable value in excess of 4000 bytes can result in an ORA-01460
    • With ODP, users moving from the 10.2 client and 10.2 ODP to the 11.1 client and 11.1.0.6.10 ODP reported an ORA-01460 error (this was a bug that should be fixed by patching ODP to the most recent version)

    It appears, according to information on bug 5872943, that the ORA-01460 associated with ODP.NET, while not an ODP error, persisted through database version 11.2 where it has been reported as fixed.