【问题标题】:Insert into oracle xmltype field using oledbcommand使用 oledbcommand 插入 oracle xmltype 字段
【发布时间】:2013-09-06 01:53:05
【问题描述】:

是否可以在 xmltype 字段中插入 xml 数据?

我正在使用以下代码,但抛出错误

ORA-01461: 只能绑定 LONG 值以插入 LONG 列

.

我不想使用 ODP.NET。有人可以给点建议吗?

OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["OracleVAT"].ConnectionString);
            try
            {
                string query = "update c_xml set DATA_XML = xmltype(?) where id=?";

                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection = con;
                cmd.CommandText = query;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@DATA_XML", DATAXML.OuterXml);
                cmd.Parameters.AddWithValue("@id", ID);
                con.Open();
                return cmd.ExecuteNonQuery();
            }
            catch
            {
            }
            finally
            {
                con.Close();
            }

【问题讨论】:

    标签: c# asp.net .net oracle


    【解决方案1】:

    你也可以使用标准的java api:

    类似这样的:

    string query = "update c_xml set DATA_XML = xmltype(?) .....
    
    Clob clob = conn.createClob();
    clob.setString(1, req_param_xml);
    statement.setClob(2, clob);
    

    【讨论】:

      猜你喜欢
      • 2015-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-31
      • 2012-07-01
      • 1970-01-01
      • 2011-07-07
      • 1970-01-01
      相关资源
      最近更新 更多