Reputation: 4497
hi i have an field has OracleClob type.I want to cast this as my string data.How can i do it in c# ?
[MapField("MSG_BODY")]
public Oracle.DataAccess.Types.OracleClob MsgBody { get; set; }
i want to set MsgBody : "This is a sample";
I have to define an oracleclob object and fill it as string text.
Upvotes: 0
Views: 2084
Reputation: 169051
I've never touched Oracle, but according to the documentation you can handle it like a byte stream.
Add a StreamWriter and you should be able to do
var sw = new StreamWriter(MsgBody, Encoding.UTF8); // Assuming you want UTF-8
sw.Write("This is a sample");
sw.Flush();
Upvotes: 2
Reputation: 67898
According to the Oracle documentation you need to write it with a buffered array, so something like this:
char[] writeBuffer = "This is a sample".ToCharArray();
this.MsgBody.Write(writerBuffer, 0, writeBuffer.Length);
this.MsgBody.Close();
this.MsgBody.Dispose();
and bear in mind I'm assuming you've created the OracleClob
with an open OracleConnection
.
Upvotes: 2