0
votes

Is it possible to insert xml data in to an xmltype field?

I am using the following code but is throwing an error

ORA-01461: can bind a LONG value only for insert into a LONG column

.

I do not want to use ODP.NET. Can somebody give any suggestion?

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();
            }
1

1 Answers

0
votes

You can also use the standard java api:

Something like this:

string query = "update c_xml set DATA_XML = xmltype(?) .....

Clob clob = conn.createClob();
clob.setString(1, req_param_xml);
statement.setClob(2, clob);