59.44 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 more specific formatting of the display of the image (with height and width tags). This function must be called from a valid Oracle APEX session and also requires that the parameters that describe the BLOB are 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
, the p_plain_url
argument must be set to TRUE
to ensure that no modal dialog code is 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
Parameter | Description |
---|---|
p_item_name |
Name of valid application page item with type FILE that contains the source type of DB column.
|
p_v1 |
Value of primary key column 1. |
p_v2 |
Value of primary key column 2. |
p_content_disposition |
Specify INLINE or ATTACHMENT , all other values ignored.
|
Example
As a PL/SQL 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 displays the BLOB
within the report if it can be displayed, and provides a download link if it cannot be displayed.
Parent topic: APEX_UTIL