Print clob data with htp.prn

As it is known, HTP.PRN procedure does not support clob data. None of the HTP.PRN procedures shown in below support CLOB data type as input.

HTP.PRN (cbuf IN VARCHAR2);

HTP.PRN (dbuf IN DATE);

HTP.PRN (nbuf IN NUMBER);

So, the following procedure provide to print clob data.

PROCEDURE HTPPRN(PCLOB IN OUT NOCOPY CLOB) 
IS
    V_TEMP VARCHAR2(32767);
    V_CLOB CLOB := PCLOB;
    V_AMOUNT NUMBER := 32000;
    V_OFFSET NUMBER := 1;
    V_LENGTH NUMBER := DBMS_LOB.GETLENGTH(PCLOB);
    V_RESULT CLOB;
BEGIN

    WHILE V_LENGTH >= V_OFFSET LOOP
        V_TEMP:= DBMS_LOB.SUBSTR(V_CLOB, V_AMOUNT, V_OFFSET);
        HTP.PRN(V_TEMP);
        V_OFFSET := V_OFFSET + LENGTH(V_TEMP);
    END LOOP;
    
END;

I hope this article will help you 🙂

3 thoughts on “Print clob data with htp.prn

  1. You can also use this

    APEX_UTIL.PRN (
    p_clob IN CLOB,
    p_escape IN BOOLEAN DEFAULT TRUE );

Leave a Reply

Your email address will not be published. Required fields are marked *