Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Download blob from function instead table field

pjsiong-JavaNetJun 23 2011 — edited Jun 23 2011
Hi,
Is that possible to download blob field content which are return by a function?
I can only download blob if the blob is in table column..

Thanks

Vincent
This post has been answered by Srecio-Oracle on Jun 23 2011
Jump to Answer

Comments

Srecio-Oracle
Answer
Hi Vincent,

I think that you can download blob content returned by a function without any problem. In the example below, the function get_blob returns a BLOB, you will have to specify the mime type and filename, and the BLOB length is obtained using the function DBMS_LOB.GETLENGTH. Finally, a call to the wpg_docload.download_file procedure is made. To call the download_file procedure you can do it through the URL or through a page with a "Branch To PL/SQL Procedure" in the "Before Header" point. More info about this kind of procedure here.
create or replace PROCEDURE  "DOWNLOAD_FILE"
(
    inID NUMBER
)
AS
    vMIME VARCHAR2(48);
    vLENGTH NUMBER;
    vFILENAME VARCHAR2(2000);
    vBLOB BLOB;
BEGIN
    vMIME := 'application/octet-stream';
    vFILENAME := 'Test.sql';
    vBLOB := get_blob(inID);
    vLENGTH := DBMS_LOB.GETLENGTH(vBLOB);
    owa_util.mime_header(nvl(vMIME, 'application/octet'), FALSE);
    htp.p('Content-length: ' || vLENGTH);
    htp.p('Content-Disposition: attachment; filename="' || SUBSTR(vFILENAME, INSTR(vFILENAME, '/') + 1) || '"');
    owa_util.http_header_close;
    wpg_docload.download_file(vBLOB);
END;
Regards,

Sergio
Marked as Answer by pjsiong-JavaNet · Sep 27 2020
pjsiong-JavaNet
Thanks Sergio, it's work..
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 21 2011
Added on Jun 23 2011
2 comments
2,884 views