2 Replies Latest reply on Jun 24, 2011 3:45 AM by pjsiong-JavaNet

    Download blob from function instead table field

    pjsiong-JavaNet
      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
        • 1. Re: Download blob from function instead table field
          Srecio-Oracle
          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
          • 2. Re: Download blob from function instead table field
            pjsiong-JavaNet
            Thanks Sergio, it's work..