Oracle. Cannot pass blob >=32 768 bytes as stored procedure parameter
See original GitHub issueDataParameter a_data = new DataParameter("a_data", new byte[32768], DataType.Blob);
a_data.Size = alert.alert.photo.content.Length;
dataConnection.ExecuteProc("ProcedureName", new[] { a_data });
ORA-01460: unimplemented or unreasonable conversion requested blob insert
Following code works:
var cmd = new OracleCommand("declare xx blob; begin dbms_lob.createtemporary(xx, false, 0); :tempblob := xx; end;");
cmd.Connection = (OracleConnection)dataConnection.Connection;
var param = new OracleParameter("tempblob", OracleDbType.Blob) { Direction = ParameterDirection.Output };
cmd.Parameters.Add(param);
cmd.ExecuteNonQuery();
var tempLob = (OracleBlob)param.Value;
tempLob.Write(new byte[32768], 0, 32768);
var comm = dataConnection.Connection.CreateCommand();
comm.CommandText = "ProcedureName";
comm.CommandType = CommandType.StoredProcedure;
var a_data = new OracleParameter("a_data", OracleDbType.Blob) { Value = tempLob };
comm.Parameters.Add(a_data );
comm.ExecuteNonQuery();
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
When saving blob or clob 32KB or larger: ORA-01460: ...
I have a byte[] property mapped to an Oracle blob and a string property ... Cannot pass blob >=32 768 bytes as stored...
Read more >ODP.NET blob PL/SQL parameter size limit? - Oracle Forums
I am trying to pass a blob into a PL/SQL procedure with the following method: cmd. ... ReadAllBytes("C:\\myfile.pdf"), ParameterDirection.
Read more >Passing byte array as parameter to stored procedure in ...
BLOB to pass the data from your java application and you can consume it with the blob data type in your stored procedure....
Read more >STORED PROCEDURE + OUTPUT PARAMETER + BLOB ...
Hi, I'm trying to use ODP.NET to retrieve a BLOB. I want to retrieve the BLOB using an output parameter of a Stored...
Read more >Pass BLOBs to Oracle Stored Procedures
As it turns out, you can pass up to 32KB directly into a stored procedure BLOB parameter with no problems. It's when you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Found a workaround by specifying
dbType
as “BLOB” explicitly via constructorMany thanks to fellows from EF Core 😉
Update: Figured out that we can’t pass
null
this way. Thats why workaround became more trickyYes, there is another Github issue about having a true, generic, stream support. Disposal is a big issue and differences between dbs as well: when writing Oracle works in push fashion (you write into
OracleBlob
first); SqlServer works in a pull fashion (you pass a stream that is read by the sql provider).In the meantime the ability to work with native DB types (e.g.
OracleBlob
) is a good enough stop-gap.I found out that if you type your model property as
OracleBlob
you can read without problems:But strangely something fishy happens if you try to write:
This write seems to work but as was observed in this issue, it also seems that the
OracleBlob
isn’t passed directly as a parameter value but rather is converted into a byte array. For instance, every byte is logged in the trace (should not be possible) and the OP here observed that values larger than 32k don’t go through (they should when using OracleBlob).It’s probably just a small issue but if it worked it would unlock writing large blobs with Linq2Db.