zoukankan      html  css  js  c++  java
  • 新增和编辑clob字段

    #region 新的数据新增和修改方法
    /// <summary>
    /// 添加信息
    /// </summary>
    /// <returns></returns>
    public static bool AddInfo(string name, string pid, string content)
    {
    OracleConnection conn = new OracleConnection(connectionstring);
    OracleCommand cmd = conn.CreateCommand();
    OracleTransaction objTran = null;
    try
    {
    conn.Open();
    objTran = conn.BeginTransaction();
    cmd.Transaction = objTran;
    //创建临时clob变量
    cmd.CommandText = "DECLARE dpClob CLOB; BEGIN DBMS_LOB.CREATETEMPORARY(dpClob, False, 0); :tmpClob := dpClob; END;";
    OracleParameter op1 = new OracleParameter("tmpClob", OracleType.Clob);
    op1.Direction = ParameterDirection.Output;
    cmd.Parameters.Add(op1);
    cmd.ExecuteNonQuery();
    OracleLob tempLob;
    tempLob = (OracleLob)cmd.Parameters[0].Value;
    tempLob.BeginBatch(OracleLobOpenMode.ReadWrite);
    byte[] buffer = Encoding.Unicode.GetBytes(content);
    tempLob.Write(buffer, 0, buffer.Length);//将值写入临时变量中
    tempLob.EndBatch();
    cmd.Parameters.Clear();
    cmd.CommandText = "insert into t_yingjiinfo (id,nodename,pid,content) values ( seq_t_yingjiinfo.nextval,'" + name + "', " + pid + ",:contentText)";
    cmd.CommandType = CommandType.Text;
    OracleParameter op2 = new OracleParameter("contentText", OracleType.Clob);
    op2.Value = tempLob;
    cmd.Parameters.Add(op2);
    cmd.ExecuteNonQuery();
    objTran.Commit();
    cmd.Parameters.Clear();
    return true;

    }
    catch
    {
    objTran.Rollback();
    return false;
    }

    finally
    {
    objTran.Dispose();
    cmd.Dispose();
    conn.Close();
    conn.Dispose();

    }


    }


    /// <summary>
    /// 更新数据 更新一般修理二维码字段 暂时只有陕西省
    /// </summary>
    /// <returns></returns>
    public static bool UpdateInfo(string bianhao, string content)
    {
    OracleConnection conn = new OracleConnection(connectionstring);
    OracleCommand cmd = conn.CreateCommand();
    OracleTransaction objTran = null;
    try
    {
    conn.Open();
    objTran = conn.BeginTransaction();
    cmd.Transaction = objTran;
    cmd.CommandText = "DECLARE dpClob CLOB; BEGIN DBMS_LOB.CREATETEMPORARY(dpClob, False, 0); :tmpClob := dpClob; END;";
    OracleParameter op1 = new OracleParameter("tmpClob", OracleType.Clob);
    op1.Direction = ParameterDirection.Output;
    cmd.Parameters.Add(op1);
    cmd.ExecuteNonQuery();
    OracleLob tempLob;
    tempLob = (OracleLob)cmd.Parameters[0].Value;
    tempLob.BeginBatch(OracleLobOpenMode.ReadWrite);
    byte[] buffer = Encoding.Unicode.GetBytes(content);
    tempLob.Write(buffer, 0, buffer.Length);
    tempLob.EndBatch();
    cmd.Parameters.Clear();
    cmd.CommandText = "update wh_qrcode set qrcode = :contentText where bianhao = '" + bianhao + "'";
    cmd.CommandType = CommandType.Text;
    OracleParameter op2 = new OracleParameter("contentText", OracleType.Clob);
    op2.Value = tempLob;
    cmd.Parameters.Add(op2);
    cmd.ExecuteNonQuery();
    objTran.Commit();
    cmd.Parameters.Clear();
    return true;
    }

    catch
    {
    objTran.Rollback();
    return false;
    }

    finally
    {
    objTran.Dispose();
    cmd.Dispose();
    conn.Close();
    conn.Dispose();
    }
    }
    #endregion

  • 相关阅读:
    onmousewheel
    Zepto 使用中的一些注意点(转)
    oninput onpropertychange 监听输入框值变化
    try catch
    center的用法
    [转]你的编程语言可以这样做吗?(map/reduce的js示范) (转)
    vue中 $event 的用法--获取当前父元素,子元素,兄弟元素
    chrome的vue插件——vue.js devtools的安装
    说明与比较:new Vue() 和 export default {}
    Vue反转字符串及join(),reverse()与 split()函数用法解析
  • 原文地址:https://www.cnblogs.com/sukhoi/p/9059642.html
Copyright © 2011-2022 走看看