Oracle Application Express includes BLOB support to enable developers to declaratively upload and download files in forms.
11.7.1 About BLOB Support in Forms
If you create a form using the Create Application Wizard, create a page of type of Form or Report and Form, create a region of type Form, or add an item to an existing form, any item whose source is a database column of type
BLOB results in an item of type File Browse. When the form is called for
INSERT, the file selected by the user is loaded into the
BLOB column. When the form is called for update, a download link is displayed to the right of the Browse button. Users can use this link to download the file.
11.7.2 About Uploading and Downloading Files into a BLOB
BLOB support does not give you all the information a typical application needs to effectively manage a
BLOB. In addition to knowing that the column is a
BLOB, more information about the file provides a better experience for the end-user. The File Browse page item has additional settings to facilitate managing this additional information completely declaratively.
For more information on File Browse settings, see File Browse in "About Item Types."
There are two different types of storage types available within the File Browse item type:
BLOBcolumn specific in Item Source Attribute - Completely declarative approach that supports configuration of the additional settings discussed here. This references a
BLOBin your own database table.
WWV_FLOW_FILES- Available for backwards compatibility. Oracle does not recommend using this in new applications.
APEX_APPLICATION_TEMP_FILES- Store the uploaded file in a temporary location that you can access with the view
APEX_APPLICATION_TEMP_FILES. Oracle Application Express automatically deletes the file at the end of the session or at the end of the upload request, depending on what you choose for Purge File At.
To provide this additional information, it is recommended that you add additional columns to your base table to store and track the MIME type, file name, last updated date and character set settings. You can accomplish this by extending your table. For example:
ALTER TABLE emp ADD (ATTACH_MIMETYPE VARCHAR2(255), ATTACH_FILENAME VARCHAR2(255), ATTACH_LAST_UPDATE DATE, ATTACH_CHARSET VARCHAR2(128));
The character set of the
BLOB is not automatically set on upload. To store the character set value for your
BLOB, you must provide an additional page item on your page which is bound to the column you use to store the character set, and where the user will be able to specify the character set for the document they are uploading.
If you manually create a form on a custom table, you can still take advantage of this feature. To do so, use the File Browse item type with a Storage Type setting of
BLOB column specified in Item Source Attribute, on a page with a DML Process type of
DML_PROCESS_ROW. This process determines the table name and primary key columns.
11.7.3 About Displaying the BLOB
If the BLOB you are working with is an image, you can display it in a form. To handle it declaratively, use the Display Image item type as described in "About Item Types." To handle it procedurally, see "Understanding BLOB Support in Forms and Reports."
11.7.4 About Removing the Image Reference
Because there is no set to
NULL when using File Browse, if you need to provide a mechanism to remove an image reference, you must include a special Remove Image button to nullify the necessary columns. Consider the following example:
UPDATE demo_product_info SET product_image = NULL, MIMETYPE = NULL, FILENAME = NULL, IMAGE_LAST_UPDATE = NULL, CHARSET = NULL WHERE product_id = :P6_PRODUCT_ID;