Use the UPDATEXML function to change element value : UPDATEXML « XML « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE TABLE myTable(
  2      id  NUMBER PRIMARY KEY,
  3      emps XMLType NOT NULL
  4  );

Table created.

SQL>
SQL> INSERT INTO myTable VALUES
  2  (1, xmltype('<?xml version="1.0" standalone="no" ?>
  3  <emps>
  4      <emp>
  5          <home_address>address</home_address>
  6      </emp>
  7  </emps>')
  8  );

1 row created.

SQL>
SQL>
SQL> update myTable
  2  set emps = updatexml(emps, '/emps/emp/home_address/text()','New York')
  3  where id = 1;

1 row updated.

SQL> commit;

Commit complete.

SQL>
SQL>
SQL> drop table myTable;

Table dropped.

SQL>
SQL>
SQL>








33.8.UPDATEXML
33.8.1.UPDATEXML function supports multiple elements
33.8.2.Update (i.e. replace) the entire XMLType column with new content
33.8.3.Update xmltype type column
33.8.4.Use UPDATEXML function to update a portion of the doc
33.8.5.Use the UPDATEXML function to change element value