46.3 GENERATE_DOCUMENT Function Signature 2

This function returns a document as BLOB using a pre-defined report query.

Syntax

APEX_PRINT.GENERATE_DOCUMENT (
    p_application_id            IN NUMBER,
    p_report_query_static_id    IN VARCHAR2,
    p_report_layout_static_id   IN VARCHAR2         DEFAULT NULL,
    p_output_type               IN t_output_type    DEFAULT c_output_pdf )
    RETURN BLOB;

Parameters

Parameter Description
p_application_id Defines the application ID of the report layout.
p_report_query_static_id Static ID of the report query (stored under application's shared components).
p_report_layout_static_id Static ID of the report layout (stored under application's shared components).
p_output_type Defines the document format. See t_output_type for the available types in Constants.

Returns

A BLOB containing the generated document.

Example

The following example generates a PDF document using a report query and a report layout defined in an application.

DECLARE
    l_document blob;
BEGIN

    l_document :=
        apex_print.generate_document (
            p_application_id             => 100,
            p_report_query_static_id     => 'MY_REPORT_QUERY',
            p_report_layout_static_id    => 'MY_REPORT_LAYOUT',
            p_output_type                => apex_print.c_output_pdf );

    apex_http.download(
        p_blob           => l_document,
        p_content_type   => 'application/pdf',
        p_filename       => 'my-report.pdf' );

END;

See Also:

Constants