Chapter 53. UTL_COMPRESS

Table of Contents

53.1. Overview
53.2. Functions
53.2.1. LZ_COMPRESS
53.2.2. LZ_UNCOMPRESS

This chapter briefly introduces the UTL_COMPRESS package, and describes how to use the functions of the package.

53.1. Overview

UTL_COMPRESS is used to compress or decompress BLOB or RAW data.

53.2. Functions

This section describes the functions provided by the UTL_COMPRESS package, in alphabetical order.

53.2.1. LZ_COMPRESS

Compresses a given data. Returns a type that matches the given type (BLOB or RAW).

Details about the LZ_COMPRESS function are as follows:

  • Prototypes

    • BLOB data

      UTL_COMPRESS.LZ_COMPRESS 
      (
          src     IN BLOB,
          quality IN BINARY_INTEGER DEFAULT 6
      ) 
      RETURN BLOB;
    • RAW data

      UTL_COMPRESS.LZ_COMPRESS 
      (
          src     IN RAW,
          quality IN BINARY_INTEGER DEFAULT 6
      )
      RETURN RAW;
  • Parameter

    ParameterDescription
    srcBLOB or RAW data to compress.
    qualityCompression ratio. Set to a value between 1 and 9. A larger value indicates higher compression ratio. (Default value: 6)
  • Example

    DECLARE
        data RAW(500);
    BEGIN    
        data := UTL_COMPRESS.LZ_COMPRESS('A1B2C3D4E5F6', 6);
    
        DBMS_OUTPUT.PUT_LINE(data);
    END;
    /

53.2.2. LZ_UNCOMPRESS

Uncompresses a given data. Returns a type that matches the given type (BLOB or RAW).

Details about the LZ_UNCOMPRESS function are as follows:

  • Prototype

    • BLOB data

      UTL_COMPRESS.LZ_UNCOMPRESS 
      (
          src     IN BLOB
      ) 
      RETURN BLOB;
    • RAW data

      UTL_COMPRESS.LZ_UNCOMPRESS 
      (
          src     IN RAW
      )
      RETURN RAW;
  • Parameter

    ParameterDescription
    srcBLOB or RAW data to decompress.
  • Example

    DECLARE
        comp_data RAW(500);
        real_data RAW(500);
    BEGIN    
        comp_data := UTL_COMPRESS.LZ_COMPRESS('A1B2C3D4E5F6', 6);
        real_data := UTL_COMPRESS.LZ_UNCOMPRESS(comp_data);
    
        DBMS_OUTPUT.PUT_LINE(real_data);    
    END;
    /