44.39 GET_BLOB_FILE_SRC Function
As an alternative to using the built-in methods of providing a download link, you can use the APEX_UTIL.GET_BLOB_FILE_SRC
function. One advantage of this approach, is the ability to more specifically format the display of the image (with height and width tags). Please note that this approach is only valid if called from a valid Oracle Application Express 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.
If the URL returned by this function is passed to APEX_UTIL.PREPARE_URL
, ensure to set the P_PLAIN_URL
argument to TRUE
to ensure that no modal dialog code is being added, when the referenced page item is on a modal page.
Syntax
APEX_UTIL.GET_BLOB_FILE_SRC (
p_item_name IN VARCHAR2 DEFAULT NULL,
p_v1 IN VARCHAR2 DEFAULT NULL,
p_v2 IN VARCHAR2 DEFAULT NULL,
p_content_disposition IN VARCHAR2 DEFAULT NULL)
RETURN VARCHAR2;
Parameters
Table 44-35 GET_BLOB_FILE_SRC Parameters
Parameter | Description |
---|---|
|
Name of valid application page ITEM that with type FILE that contains the source type of DB column. |
|
Value of primary key column 1. |
|
Value of primary key column 2. |
|
Specify |
Example
As a PLSQL Function Body:
RETURN '<img src="'||APEX_UTIL.GET_BLOB_FILE_SRC('P2_ATTACHMENT',:P2_EMPNO)||'" />';
As a Region Source of type SQL:
SELECT ID, NAME,CASE WHEN NVL(dbms_lob.getlength(document),0) = 0
THEN NULL
ELSE CASE WHEN attach_mimetype like 'image%'
THEN '<img src="'||apex_util.get_blob_file_src('P4_DOCUMENT',id)||'" />'
ELSE
'<a href="'||apex_util.get_blob_file_src('P4_DOCUMENT',id)||'">Download</a>'
end
END new_img
FROM TEST_WITH_BLOB
The previous example illustrates how to display the BLOB
within the report, if it can be displayed, and provide a download link, if it cannot be displayed.
See Also:
"Understanding BLOB Support in Forms and Reports" in Oracle APEX App Builder User’s Guide
Parent topic: APEX_UTIL