Oracle blob字段的插入和更新

 所以,如果对于新插入的记录,存在blob类型的字段,需要在blob字段中先使用EMPTY_BLOB(),让该条记录先保存到数据库中;

然后,使用更新语句的方式,更新blob字段的值,代码如下:

//构造更新语句:

string strSQL="update  tablename  set Rangecoords=:coords where 查询条件";

//创建Oracle参数

 byte[] bigTextByte = System.Text.Encoding.UTF8.GetBytes(bigText);
  OracleParameter    coordsPara = new OracleParameter(":coords", OracleType.Blob, bigTextByte.Length);
  OracleParameter    coordsPara.Value = bigTextByte;

OracleCommand cmd = new OracleCommand();
  cmd.Connection = conn;
  cmd.CommandText = strSQL;

cmd.Parameters.Add(coordsPara);

cmd.ExecuteNonQuery();

这样就问题就顺利的解决了!

猜你喜欢

转载自www.linuxidc.com/Linux/2016-12/138957.htm
今日推荐