XML Database (MOSC)

MOSC Banner

How to insert xml file data to atble having column type as xmltype

edited Nov 25, 2021 6:35PM in XML Database (MOSC) 4 commentsAnswered

Hello , I have a table defined as

CREATE TABLE TEST_TABLE (docid VARCHAR2(200), type VARCHAR2(200),xmlfile XMLTYPE) ;


and from java , i m trying to insert xml data as below

 String query = "INSERT INTO TEST_TABLE (docid,type,xmlfile) VALUES (?,?,XMLType(?)) ";

     

      // Get the statement Object

      PreparedStatement statement = jdbcConection.getJdbcConnection().prepareStatement(query);


      // Get the OracleClob instance from xmlString

      statement.setString(1, "0BCFF8F0");

      statement.setString(2, "Topic");


      clob =(OracleClob) jdbcConection.getJdbcConnection().createClob();

      clob.setString(1, "am new to xml db");   

      statement.setObject(3, clob);


      // Execute the prepared statement

      if (statement.executeUpdate () == 1)

      {

        System.out.println ("Successfully inserted");

      }



getting the error java.sql.SQLException: ORA-22922: nonexistent LOB value

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center