1

I am coding in C# and I have following problem with Oracle DB. I would like to store some TEXT in BLOB column but I do not know how. Do you have any idea how to change my code?

String textValue = "Some example of text..."

oraCommand.CommandText = "UPDATE BLOB_TABLE SET BLOB_COLUMN = :data WHERE ID='123'";
                oraCommand.Parameters.Add(":data", OracleDbType.Blob);
                oraCommand.Parameters[":data"].Value = textValue;
                oraCommand.ExecuteNonQuery();
            }
1
  • a BLOB or a CLOB? a BLOB is a binary data type and will expect a byte[] as the value. you need to convert your string to a byte arary. Commented May 9, 2017 at 14:09

1 Answer 1

3

You must remove ":" while binding parameters. And BLOB is binary object, you should convert string to byte array. You should use CLOB for character large objects.

String textValue = "Some example of text..."

oraCommand.CommandText = "UPDATE BLOB_TABLE SET BLOB_COLUMN = :data WHERE ID='123'";
OracleParameter param  =  oraCommand.Parameters.Add("data", OracleDbType.Blob);
param.Value = Encoding.ASCII.GetBytes(textValue);
oraCommand.ExecuteNonQuery();
Sign up to request clarification or add additional context in comments.

Comments

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.