54.7 BLOB2CLOBBASE64 Function

This function converts a BLOB data type into a CLOB that is base64-encoded. This is often used when sending a binary as an input to a web service.

Syntax

APEX_WEB_SERVICE.BLOB2CLOBBASE64 (
    p_blob      IN BLOB,    
    p_newlines  IN VARCHAR2 DEFAULT 'Y',
    p_padding   IN VARCHAR2 DEFAULT 'N' )
RETURN CLOB;

Parameters

Parameter Description
p_blob The BLOB to convert into base64-encoded CLOB.
p_newlines Whether the generated base64 content contains line breaks.
p_padding Whether to pad the generated base64 content with "=" so that the length becomes a multiple of 4.

Example

The following example gets a file that was uploaded from the apex_application_files view and converts the BLOB into a CLOB that is base64-encoded.

DECLARE
    l_clob    CLOB;
    l_blob    BLOB;
BEGIN
    SELECT BLOB_CONTENT
      INTO l_BLOB
      FROM APEX_APPLICATION_FILES
      WHERE name = :P1_FILE;

    l_CLOB := apex_web_service.blob2clobbase64(l_BLOB);
END;