Reputation: 189
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();
}
Upvotes: 1
Views: 2469
Reputation: 6944
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();
Upvotes: 3