Search code examples
javaoracle-databaseplsqlcompressionclob

How to compress XML (CLOB data) in Oracle?


Oracle 11.2.0.4

I trying to compress XML (XMLTYPE dbfield) via java class methods href here: LOB compression

The class was successfully compiled.

SELECT  OBJECT_NAME,
        OBJECT_TYPE
    FROM DBA_OBJECTS
    WHERE OBJECT_NAME LIKE '%LobCompress%'
    ORDER BY 1;
-------------------

OBJECT_NAME OBJECT_TYPE
LobCompressor   JAVA CLASS
LobCompressor   JAVA SOURCE

but error appears in RT when calling this methods:

DECLARE
dr MY_USER.ORDER_CONFIG%ROWTYPE;
bZipped BLOB;
...
SELECT * INTO dr
            FROM MY_USER.ORDER_CONFIG oc
            WHERE oc.ORDER_NO = '3751017';


bZipped := MY_USER.PKG_COMPRESSOR.CLOB_COMPRESS(dr.CONFIG_XML);

ORA-29540: class LobCompressor does not exist ORA-06512: at "MY_USER.PKG_COMPRESSOR", line 10 ORA-06512: at "MY_USER.PKG_COMPRESSOR", line 39 ORA-06512: at line 13

dr.CONFIG_XML has not empty / not null value

What i need to do for correct script work?

PS this is my first time i am trying to use java class in pl sql


Solution

  • I think nowadays the most useful way for compressing XMLTYPE and/or LOB is to make compression on tablespace level.

    When you create columns of XMLTYPE or any LOB you have to specify LOB_storage_clause. Compress entire tablespace where such objects are stored.

    See also XMLType_storage:

    In earlier releases, binary XML data is stored by default in a BasicFiles LOB. Beginning with Oracle Database 11g Release 2 (11.2.0.2), if the COMPATIBLE initialization parameter is 11.2 or higher and you do not specify BASICFILE or SECUREFILE, then binary XML data is stored in a SecureFiles LOB whenever possible. If SecureFiles LOB storage is not possible then the binary XML data is stored in a BasicFiles LOB.

    SecureFiles provide compression, deduplication, and encryption.