Home

Deprecated or desupported package DBMS_XMLSAVE should not be used

Description

    This rule flags any reference to the PL/SQL package DBMS_XMLSAVE or its sub‑programs (insertXML, updateXML, deleteXML, newContext, closeContext) in application code.

    DBMS_XMLSAVE was officially deprecated starting with Oracle 18c and is completely desupported (removed) in Oracle 21c and later. Continuing to compile or deploy code that calls this package will cause compilation failures or runtime errors after a database upgrade.

    Use regular SQL DML with standard XQuery and SQL/XML to store and manage XML data. This standard approach provides a future-proof way to handle XML in the database.

Key Benefits

  • Upgrade Safety: Guarantees that code will compile and run on Oracle 21c and future releases.
  • Modern Standards: Leverages SQL/XML functions compliant with ANSI standards and best practices.
  • Lower Maintenance Cost: Eliminates hidden dependencies on obsolete Java‑based libraries bundled with older database versions.
  • Security & Supportability: Keeps the application within the scope of Oracle’s current security patches and support policies.

 

Non-compliant Code Example

DECLARE
  ctx     DBMS_XMLSAVE.ctxType;       --Non compliant code
  rowsnum NUMBER;
  xmlDoc  CLOB :=
    '7788SCOTT1000';
BEGIN
  ctx     := DBMS_XMLSAVE.newContext('EMP');       --Non compliant code
  rowsnum := DBMS_XMLSAVE.insertXML(ctx, xmlDoc);       --Non compliant code
  DBMS_XMLSAVE.closeContext(ctx);       --Non compliant code
END;

Compliant Code Example

INSERT INTO emp (empno, ename, sal)
SELECT x.empno, x.ename, x.sal
FROM   XMLTABLE(
         '/ROWSET/ROW'
         PASSING XMLTYPE(
           '7788SCOTT1000')
         COLUMNS
           empno NUMBER       PATH 'EMPNO',
           ename VARCHAR2(20) PATH 'ENAME',
           sal   NUMBER       PATH 'SAL'
       ) x;    --Compliant code
Visual Expert 2025
 VEPLSQLRULE197