1

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.

4
  • 2
    have you looked at the OracleDataType mappings here msdn.microsoft.com/en-us/library/yk72thhd%28v=vs.110%29.aspx Commented Mar 25, 2015 at 17:55
  • 1
    OracleDataReader reader perhaps a BinaryReader would work or take a look at this link devart.com/dotconnect/oracle/articles/lob.html Commented Mar 25, 2015 at 17:57
  • @MethodMan thanks for that. I found the ODP.NET version of that page here docs.oracle.com/cd/B28359_01/win.111/b28375/featTypes.htm and they state I need to use an OracleBinary if my column type is LONG RAW. I think I need to change my column to a BLOB and use a byte array. Commented Mar 25, 2015 at 18:06
  • 1
    that's good assuming you can change the data type of the column with already loaded data.. which you should be able to do.. glad you were able to find a viable solution "+1" Commented Mar 25, 2015 at 18:17

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

But how do you rad the byte[] in .net. I am getting [0] all the time?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.