How to display the download link with get_blob or get_blob_file_src?

Hello

I fight to display a download link in a report of SQL query.
Based on the condition, I need to create a report of sql query that the source contains a series of query union select.

Example here
WITH current_engagement AS)
SELECT engagement_id, pn, ethnicity, date_joined_aodt_court, defendant_id, case_manager_name
participation_conditions, discharge_conditions
COMMITMENT
WHERE defendant_id =: PXX_DEF
AND date_joined IS NOT NULL
AND (date_terminated IS NULL or to_date(date_joined,'DD/MM/YYYY') > to_date(sysdate,'DD/MM/YYYY'))
AND active = 1 AND ROWNUM = 1
ORDER BY defendant_id DESC
)
SELECT def.first_name, def.middle_name, def.surname, to_char (def.pn) "PN", to_char (def.nhi_number) AS 'IHN ".
, ce.ethnicity, to_char (ce.date_joined) as ce.discharge_conditions, ce.participation_conditions, ce.case_manager_name, 'DATE_JOINED '.
THE DEFENDANT def INNER JOIN current_engagement this
ON def.def_id = ce.defendant_id
UNION ALL

Select the < b > 2. Phase number < /b > ', ' < b > Date started < /b > "," < b > Date completed < /b > ', '< /b > < b > Notes', null
null, null, null, null, null
of the double
UNION ALL
SELECT TO_CHAR (NVL (ph.phase_number, 'No. Phase found')), TO_CHAR (ph.date_started, ' DD/MM/YYYY'), TO_CHAR (ph.date_finished, ' DD/MM/YYYY'), ph.notes, null
null, null, null, null, null
FROM phase_membership INNER JOIN current_engagement ph this
ON ph.mpm_eng_id = ce.engagement_id
WHERE the to_date(ph.date_started,'DD/MM/YYYY') < = TO_DATE(sysdate,'DD/MM/YYYY')
AND (ph.date_finished IS NULL
TO_DATE(ph.date_finished,_'DD/MM/YYYY') or > = TO_DATE(sysdate,'DD/MM/YYYY'))
AND ph.active = 1
UNION ALL
-Selects more
-then select it last is to list all documents with download links
Select the < b > 6. "The document Date < /b > ', 'Type of paper < b > < /b >', 'Description of < b > < /b >', '< b > download < /b > '.
null, null, null, null, null, null
of the double

UNION ALL
SELECT TO_CHAR (doc.date_received), doc.document_type, doc.comments, TO_CHAR (dbms_lob.getlength (doc.) UPLOADED_FILE))
null, null, null, null, null, null
DOCUMENT doc INNER JOIN current_engagement this
ON doc.d_eng_id = ce.engagement_id
WHERE doc.active = 1

This report is generated correctly.
But the requirement also ask to post a download link. And because it's the Union chooses, selects all next must be same as the types of data in column select it first.
In this case, it must be CHARACTER. otherwise, it will generate the error like below
ORA-01790: expression must have same type of data, matching expression


Then I followed the step of GET_BLOB_FILE_SRC function of
http://docs.Oracle.com/CD/E14373_01/apirefs.32/e13369/apex_util.htm#AEAPI129
I turn my last selection in
SELECT TO_CHAR (doc.date_received), doc.document_type, doc.comments,
CASE WHEN NVL (dbms_lob.getlength (doc.) (UPLOADED_FILE), 0) = 0
THEN NULL
ON THE OTHER
"Download".
END
null, null, null, null, null, null
DOCUMENT doc INNER JOIN current_engagement this
ON doc.d_eng_id = ce.engagement_id
WHERE doc.active = 1

Which is the result within the Group
http://app_address_here/f?p=208:48:1303335952329758:

whereas if I use the interactive report link is
http://app_address_here/apex_util.get_blob?s=1303335952329758 & a = 208 & c = 66645817090447568 & p = 48 & 12 = K1 & K2 = & CK = A18D20D407435BD649EA3399EC27BC00 & RT = CR
and it works well.

I search and know that get_blob_file_source a link to the source of the column / field name located in the first parameter.
If I put the UPLOADED_FILE column of the DOCUMENT table in the source of the REF. column
But it still does not show anything close to the correct one which is generated by interactive report.

If anyone has any ideas, please help. If I need to manually write using get_blob, please give me an example.
I have urgent need of this report.
The version of the SUMMIT that we use is Application Express 4.0.2.00.07
And I can't ask an update 4.2 until the end of next year.

Help, please.
Thank you very much in advance.
Ann.

Hello Ann,.
Here you can view and download the example:

http://Apex.Oracle.com/pls/Apex/f?p=63066:1

Please let me know if you need to access the workspace.

Tip, please read the FAQ section. had you put your thread in a better format, you would have got a quicker response :)

Kind regards
Fateh

Tags: Database

Similar Questions

Maybe you are looking for