How to insert string into oracle clob type with Dapper?

dapper oracle

Question

I have a simple question about dapper with Oracle database, when I was trying to insert a large size of string into oracle clob, it throws exception says:

Specified argument was out of the range of valid values.

then I was trying to modify this part

param.Add(name: "body", value: obj.BODY, direction: ParameterDirection.Input);

I can't specify OracleDbType.Clob

What should I change to make it work?

Popular Answer

Its works for me...

byte[] newvalue = System.Text.Encoding.Unicode.GetBytes(mystring);
var clob = new OracleClob(db);
clob.Write(newvalue, 0, newvalue.Length);

var parameter = new OracleDynamicParameters();    
parameter.Add("PCLOB", clob);


var command = @"Insert into MYTABLE(CLOBFIELD) values (:PCLOB)";
var t = db.Execute(command, parameter);

You could get OracleDynamicParameters class in https://gist.github.com/vijaysg/3096151



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why