48.1 BLOB_TO_CLOB Function

This function converts a BLOB to a temporary CLOB.

Syntax

APEX_UTIL.BLOB_TO_CLOB (
    p_blob              IN BLOB,
    p_charset           IN VARCHAR2 DEFAULT NULL,
    --
    p_in_memory         IN VARCHAR2 DEFAULT 'Y',
    p_free_immediately  IN VARCHAR2 DEFAULT 'Y' )
RETURN CLOB;

Parameters

Table 48-1 BLOB_TO_CLOB Parameters

Parameter Description
p_blob BLOB to be converted to a CLOB.
p_charset Character set of the BLOB to be converted. If omitted, the database character set is assumed and no character set conversion happens.
p_in_memory If Y is specified, create the temporary LOB in memory.
p_free_immediately If Y is specified, clean up the temporary LOB after the top-level call.

Returns

Temporary CLOB containing the BLOB contents.

Example

The following example grabs website contents as BLOB and convert to a CLOB.

DECLARE
    l_clob clob;
    l_blob blob;
BEGIN
    l_blob := apex_web_service.make_rest_request_b(
    p_url => 'https://www.oracle.com/',
    p_http_method => 'GET' );

    l_clob := apex_util.blob_to_clob(
    p_blob => l_blob );

    sys.dbms_output.put_line( 'The CLOB has ' || sys.dbms_lob.getlength( l_clob ) || ' bytes.' );
    sys.dbms_output.put_line( '--------------------------------' );
    sys.dbms_output.put_line( sys.dbms_lob.substr( l_clob, 80, 1 ) );
END;