How can I insert a string into an oracle clob using Dapper?
I have a simple dapper question with an Oracle database, when I tried to insert a large size string into the orator's box, it throws an exception:
Specified argument was out of the range of valid values.
then i tried to change this part
param.Add(name: "body", value: obj.BODY, direction: ParameterDirection.Input);
I cannot indicate OracleDbType.Clob
What should I change to make it work?
+3
source to share
1 answer
His 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 can get the OracleDynamicParameters class at https://gist.github.com/vijaysg/3096151
+1
source to share