Previous Next JavaScript must be enabled to correctly display this content

## 8.13 Understanding BLOB Support in Forms and Reports

Oracle APEX includes declarative `BLOB` support to enable developers to declaratively upload files in forms, and download or display files in reports.

`BLOB` display and download can also be authored procedurally using PL/SQL. This section describes how to upload, download and display files, and how to manage additional file attributes such as `MIME` type and file name that are important for proper management of files stored in `BLOB` columns. Using this functionality, you can easily extend your APEX applications to manage files including images, documents, videos, and so on.

- About BLOB Support in Reports
  Oracle APEX includes `BLOB` support for both classic and interactive reports.
- Including a Download Link
  Include a download link in a report by adding columns to your report query.
- Displaying a BLOB Image in a Report
  Display a `BLOB` image in a report by adding columns to your report query.
- About Working With BLOBs Procedurally
  As an alternative to using the built-in methods of providing a download link, use the `APEX_UTIL.GET_BLOB_FILE_SRC` function.
- About Other Declarative Download Options
  Learn about other declarative options to download files.

Parent topic: Developing Reports

### 8.13.1 About BLOB Support in Reports

Oracle APEX includes `BLOB` support for both classic and interactive reports.

If you use a wizard to create a report and include a column of type `BLOB`, this column will not be included in the report definition. To include a `BLOB` download link, additional attributes have to be configured after generation to provide the download capability.

Parent topic: Understanding BLOB Support in Forms and Reports

### 8.13.2 Including a Download Link

Include a download link in a report by adding columns to your report query.

By default, `BLOB` columns do not display in a report. Reports that include a `BLOB` column will display the text `[unsupported data type]` for the column. To include a download link in a report, you need to add a number column to your report query and select the display type Download BLOB.

To include a download link:

1. View the page containing the report in Page Designer.
2. If your report’s Source is based on a Table / View, change this attribute to SQL Query.
   The SQL Query attribute automatically generates the corresponding query.
3. Add a new numeric/integer column expression to your query, typically the size of the file referenced by the download link. If the length is 0, the `BLOB` is `NULL`, and no download link is displayed.

   To calculate the file size use an expression such as:

       ...
          col_n,
          sys.dbms_lob.getlength([blob_column]) as download
       from ...

4. Find Identification of your download column. From Type, select Download BLOB.
5. Find BLOB Attributes. Configure the following:
   1. Table Name - Enter the table name, which stores the `BLOB` content you want to display. You can type in the table name or pick from the list of available tables.
   2. BLOB Column - Select the `BLOB` column from the table, which stores the `BLOB` content you want to display.
   3. Primary Key Column(s) - Select the primary key column(s) from the table, which stores the `BLOB` content you want to display. If the primary key of this table has more than two columns, you must select the ROWID column.
   4. Mime Type Column – Optionally, select the mime type column from the table, which stores the `BLOB` content you want to display.
   5. Filename Column – Optionally, select the filename column from the table, which stores the `BLOB` content you want to display.
   6. Last Updated Column – Optionally, select the last updated column from the table, which stores the `BLOB` content you want to display. Ideally, this column represents the update of the file, not other column’s values.
   7. Character Set Column – Optionally, select the character set column from the table, which stores the `BLOB` content you want to display.
6. Find Appearance:
   1. Download Text - Enter the text to use for the download link on the page.
   2. Content Disposition – Choose between Attachment and Inline.
      Attachment forces a download of the file, while Inline will try to render the file in the browser, if possible. The inline behavior is depending on browser capabilities and configuration with respect to the file’s mime type.
7. Click Save or Save and Run Page.

Parent topic: Understanding BLOB Support in Forms and Reports

### 8.13.3 Displaying a BLOB Image in a Report

Display a `BLOB` image in a report by adding columns to your report query.

If the `BLOB` you are working with is an image, you can display it in a report using the display type Display Image.

To display a BLOB that is an image in a report:

1. View the page containing the report in Page Designer.
2. If your report’s Source is based on a Table / View, change this attribute to SQL Query.
   The SQL Query attribute automatically generates the corresponding query.
3. Add a new numeric/integer column expression to your query, typically the size of the image file. If the length is 0, the BLOB is NULL and no image is displayed.

   To calculate the file size use expression such as:

       ...
          col_n,
          sys.dbms_lob.getlength([blob_column]) as image
       from ...

4. Identification, Type - Select Display Image.
5. Configure BLOB Attributes:
   1. BLOB Attributes, Table Name - Enter the table name, which stores the `BLOB` content you want to display. You can type in the table name or pick from the list of available tables.
   2. BLOB Attributes, BLOB Column - Select the `BLOB` column from the table, which stores the `BLOB` content you want to display.
   3. BLOB Attributes, Primary Key Column(s) - Select the primary key column(s) from the table, which stores the `BLOB` content you want to display. If the primary key of this table has more than two columns, you must select the ROWID column.
   4. BLOB Attributes, Mime Type Column – Optionally, select the mime type column from the table, which stores the `BLOB` content you want to display.
   5. BLOB Attributes, Filename Column – Optionally, select the filename column from the table, which stores the `BLOB` content you want to display.
   6. BLOB Attributes, Last Updated Column – Optionally, select the last updated column from the table, which stores the `BLOB` content you want to display. Ideally, this column represents the update of the file, not other column’s values.

   If the `BLOB` column contains a file other than an image and depending on how the browser handles the file type, the content will not display.

   The image will be rendered as-is, meaning the image displays with its original height and width in pixels.

6. Accessibility, Image Description - Provide text or a reference to a column containing the text to describe the image. This text will be used as alternative text for the image and will be rendered with the `<alt>` tag. If no Image Description is provided, then the tag with double quote will be rendered. To learn more, click the Help tab in the central pane.
7. To add some custom CSS to your page so that the images fits in your report:
   1. Advanced, HTML DOM ID - Enter the HTML DOM ID for the column, for example, `my_report_image_column`. To learn more, click the Help tab in the central pane.
   2. CSS, Inline Attribute - Add CSS code to the Inline Attribute. For example, to display the image with a height of 25 pixels you would add:

          td[headers="my_report_image_column"] img {
              height: 25px;
          }

8. Click Save or Save and Run Page.

Parent topic: Understanding BLOB Support in Forms and Reports

### 8.13.4 About Working With BLOBs Procedurally

As an alternative to using the built-in methods of providing a download link, use the `APEX_UTIL.GET_BLOB_FILE_SRC` function.

One advantage of using the `APEX_UTIL.GET_BLOB_FILE_SRC` function is the ability to more specifically format the display of the image (with height and width tags). Note that this approach is only valid if called from a valid Oracle APEX session. Also, this method requires that the parameters that describe the `BLOB` to be listed as the format of a valid item within the application. That item is then referenced by the function.

See Also:

GET_BLOB_FILE_SRC Function in Oracle APEX API Reference

Parent topic: Understanding BLOB Support in Forms and Reports

### 8.13.5 About Other Declarative Download Options

Learn about other declarative options to download files.

Oracle APEX also offers other declarative options to download files, such as a built-in processes or dynamic action plug-ins. Each of these solutions offer simple downloads based on a SQL query you provide.

See Also:

Managing Dynamic Actions and Understanding Page Processes

Parent topic: Understanding BLOB Support in Forms and Reports