79792729

Date: 2025-10-17 04:02:09
Score: 3
Natty:
Report link

heres 2025, and i have the same problem when reading blob in old db with Oracle Managed Data Access Client. core 23 or any other vers, within .net core.

hard to solve, but by telling ai "read blob from oracle without using oracledatareader", answer comes, and it does work.

////connection prepared

string sql = @"
         DECLARE
                 l_blob BLOB;
         BEGIN
             select blob_field into l_blob
             from  your_table_name 
             where id = :id;
             
             :BlobData:= l_blob;   
         END;";  

using (var transaction = conn.BeginTransaction())
{
    try
    {
        //reading config
        var getBlobCmd = new OracleCommand(sql, conn);
        getBlobCmd.Parameters.Add(new OracleParameter("id", id));

        var blobParam = new OracleParameter("BlobData", OracleDbType.Blob)
        {
            Direction = ParameterDirection.Output
        };
        getBlobCmd.Parameters.Add(blobParam);

        //read
        getBlobCmd.ExecuteNonQuery();

        //gets blob value here
        var oracleBlob = blobParam.Value as OracleBlob;
        if (oracleBlob == null || oracleBlob.Length == 0)
            throw new InvalidOperationException("blob length is 0");


        transaction.Commit();

    }
    catch (Exception)
    {
        transaction.Rollback();
        throw;
    }
}
Reasons:
  • Blacklisted phrase (1): i have the same problem
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): i have the same problem
  • Low reputation (1):
Posted by: user31704031