Previous
Previous
 
Next
Next

About BLOB in Forms

If you create a Form (either using the Create Application Wizard, create page of type Form - or Report and Form, or create region of type Form) or add an item to an existing form, any items whose source is a database column of type BLOB will result in an item of type File Browse. When the form is called for INSERT, the file selected by the user will be 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.

Populating the BLOB and Providing Download

The defaulted 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 will provide a better experience for the end-user. To facilitate managing this additional information, the 'Source' attribute of an item has been extended to have additional components (in addition to DB_COLUMN):

Position Attribute Required Description
1 Column containing BLOB Yes Case sensitive name of column of type BLOB.
2 MIME type Column No Case sensitive column name used to store the MIME type.
3 Filename Column No Case sensitive column name used to store the filename of the BLOB. If null, the column name is used as the default when user downloads the file.
4 Last Update Column No Case sensitive column name used to store the last update date of the BLOB. If used, the HTTP header of the file download will indicate the date of last modification and browsers will be able to cache the BLOB. If not specified, the browser may not be able to cache files.
5 Character Set Column No Case sensitive column name used to store the character set of the BLOB. Most relevant for Asian languages which may need to maintain the character set encoding.
6 Content Disposition No Specify inline or attachment. All other values ignored. attachment is the default, inline can only be respected if a MIME type is specified.
7 Download Text No String used for the download link. If nothing is provided, Download will be used. Note this will support substitutions (useful for translated applications).

Consider the following example:

RESUME:RESUME_MIMETYPE:RESUME_FILENAME:RESUME_LAST_UPDATE::attachment:Resume

If you have an item of type File Browse, whose source is Database Column that contains at least one colon (for example, RESUME:), you will see a link below the Source BLOB Download Format Mask. This popup assists in entering all the parameters necessary for the BLOB format.

At a minimum, you must specify the database BLOB column with at least one trailing colon (for example, RESUME:). This preserves compatibility with Oracle Application Express release 3.0.1.


Tip:

To see a real example, go to Sample Application, page 6 (Add/Modify Products), and review the item P6_PRODUCT_IMAGE. See "Running a Demonstration Application".

To provide this additional information, Oracle recommends you add additional columns to your base table to store and track the MIME type and file name attributes. You can accomplish this simply by extending your table, for example:

ALTER TABLE emp ADD 
   (ATTACH_MIMETYPE     VARCHAR2(255),
    ATTACH_FILENAME     VARCHAR2(255),
    ATTACH_LAST_UPDATE  DATE);

If you manually create a form, you can still take advantage of this feature. You simply use the format described within an item of type File (File Browse) on a page with a DML Process of type DML_PROCESS_ROW. This process will determine the table name and primary key columns.

Displaying the BLOB

If the BLOB you are working with is an image, you can display it in the form as well. See "Working With BLOBs Procedurally".

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;

Tip:

To see a real example, go to Sample Application, page 6 (Add/Modify Products), Delete Image process. See "Running a Demonstration Application".