farbodg
farbodg

Reputation: 705

OracleDataReader returning empty byte array for BLOB column

I'm attempting to retrieve a certificate stored as a BLOB in an Oracle database but I keep getting an empty byte array back. Here's a code snippet:

        OracleCommand command = new OracleCommand(QUERY_GETURLS, connection);

        OracleDataReader reader = null;

        try
        {
            connection.Open();
            reader = command.ExecuteReader();

            while (reader.Read())
            {
                string organization = reader["Organization"].ToString();
                string type = reader["Type"].ToString();
                string url = reader["DestinationUrl"].ToString();
                byte[] certificate = (byte[])reader["Certificate"];

Organization, type and URL are returned fine, but the certificate field always returns an empty byte array. If I manually run the same query against the database, the BLOB column is returned. The column data type is a LONG RAW and I am using ODP.NET.

Upvotes: 1

Views: 1945

Answers (1)

farbodg
farbodg

Reputation: 705

Thanks to MethodMan, I was able to find the appropriate page that shows what data types to use for ODP.NET:

docs.oracle.com/cd/B28359_01/win.111/b28375/featTypes.htm

I can use an OracleBinary for a LONG RAW. After further research, it seems that the Oracle community is going away from LONG RAW and towards a BLOB. I am going to switch my column data type to BLOB and use a byte array.

Upvotes: 1

Related Questions