Downloading blob content from a custom table

In our hosted Apex application, the following code from the Application Express Developer's Guide works great for allowing a user to download blob content from one of our custom tables via a download button. However, the code doesn't work on the Oracle Cloud because the "owa_util" package is no longer available. The code is as follows:
CREATE OR REPLACE PROCEDURE download_my_file(p_file in number) AS
v_mime VARCHAR2(48);
v_length NUMBER;
v_file_name VARCHAR2(2000);
Lob_loc BLOB;
BEGIN
SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
INTO v_mime,lob_loc,v_file_name,v_length
FROM file_subjects
WHERE id = p_file;
-- set up HTTP header
-- use an NVL around the mime type and
-- if it is a null set it to application/octect
-- application/octect may launch a download window from windows
owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
-- set the size so the browser knows how much to download
htp.p('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a save as
htp.p('Content-Disposition: attachment; filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
-- close the headers
owa_util.http_header_close;
-- download the BLOB
wpg_docload.download_file( Lob_loc );
end download_my_file;
Besides using web services, does anyone know of a way to do this? Is there a way to add access to the "owa_util" package in the cloud? I have also tried apex_util.get_blob_file_src but that is also unavailable in the Oracle Cloud.
Thanks,
Steve

Following Joel's advice:
The way I solved this was to split the code between two page processes and one application process. The download button first calls a page process to move the report data into a blob column and then calls another page process which is of "run application process" type. This calls the application level process where the download code, shown below, is called.
Notice the following changes to the code from the one posted earlier (also from Joel)
1) added sys.htp.init;
2) "sys." to all htp, owa and wpg_docload calls
3) added apex_application.stop_apex_engine; after the wpg_docload statement at the bottom of the script.
Now the download button launches a "save as" dialog box and the report content is downloaded to the client.
The code now looks like:
CREATE OR REPLACE PROCEDURE download_my_file(p_file in number) AS
v_mime VARCHAR2(48);
v_length NUMBER;
v_file_name VARCHAR2(2000);
Lob_loc BLOB;
BEGIN
SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
INTO v_mime,lob_loc,v_file_name,v_length
FROM oehr_file_subject
WHERE id = p_file;
-- set up HTTP header
-- use an NVL around the mime type and
-- if it is a null set it to application/octect
-- application/octect may launch a download window from windows
sys.htp.init;
sys.owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
-- set the size so the browser knows how much to download
sys.htp.p('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a save as
sys. htp.p('Content-Disposition: attachment; filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
-- close the headers
sys.owa_util.http_header_close;
-- download the BLOB
sys.wpg_docload.download_file( Lob_loc );
apex_application.stop_apex_engine;
end download_my_file;
Thanks Joel for your help.
Steve

Similar Messages

  • Download a Document from a custom table

    Hello,
    Currently I maintain HTML documents in a CLOB and I want to provide the user a means to download it as a file.
    I followed the instructions for this in the HOWTO but I am having problems executing my procedure via a URL along the lines of:
    #OWNER#.my_proc?my_var=1
    I get the following error:
    The requested URL /pls/htmldb/scott.my_proc was not found on this server.
    Any tips on how to debug this? I'm pretty sure it has nothing to do with HTML DB itself but thought someone in this forum would know where to point me.
    Regards

    hey peter--
    did you already grant execute on scott.my_proc to your mod_plsql DAD user or Public? not doing so is one cause for error in these cases. anyhow, that error's a generic one, so you'd probably want to check your apache error logs if you wanted more info. if it were me, i'd grant execute first to see if that worked. try either or both angles when you get a chance and let us know if you need further assistance.
    regards,
    raj

  • Converting an image as a blob content from .gif format to .jpg format

    Hi
    Does anyone know how to convert a blob content from .gif format to .jpg format?
    I've tried looking at the process-method of intermedia, but I can't figure out how it's supposed to work... I'm on a 10.2.0.2 standard edition database
    I simply have a blob containing a gif-image, and I want it to be convertet to a jpg-image for further use
    Can anyone help?
    Thank you
    /Klaus Mogensen

    Hi
    Does anyone know how to convert a blob content from
    .gif format to .jpg format?
    I've tried looking at the process-method of
    intermedia, but I can't figure out how it's supposed
    to work... I'm on a 10.2.0.2 standard edition
    database
    I simply have a blob containing a gif-image, and I
    want it to be convertet to a jpg-image for further
    useWhat OS is the database running on? If it is a *nix flavour, you can call out to image magick convert utility (it is pre-installed on most linux variants, and you can compile it from source for other unixes). So you would probably store the blob into a temp file on the database server, call out to the shell to execute convert, and then load a blob from the converted file. See http://imagemagick.org for more information.
    If that is not an option, you might be able to use Java Advanced Imaging API from a Java stored proc to convert between those image formats. See http://java.sun.com/products/java-media/jai/downloads/download-1_1_2.html
    gojko adzic
    http://gojko.net

  • Giving Error When Selecting From a Custom Table

    There is a custom report 'Z*'  which archives data.
    In this report, while selecting data(needs to be archived) from a custom table 'Z*_T', giving runtime error in Production Server.
    The select statement is written below :
    *data izX like z_t occurs 1000 with header line._
    *select * from z*t into table i_zX.*_
    How can I change the select statement so that it will work properly?

    Sas..
    From your example code it appears you are trying to use a wild card for both your dbtable and the internal table.
    To do this, you will lilkely need to use a Field Symbol for the target internal table and your FROM will need to be a varible
    FROM (dbtabname)
    The ABAP Helps gives this example for the Select Table
    DATA  TABNAME(10).
    DATA: BEGIN OF WA,
            ID   LIKE SCUSTOM-ID,
            NAME LIKE SCUSTOM-NAME,
            REST(134),
          END OF WA.
    TABNAME = 'SCUSTOM'.
    SELECT * INTO WA FROM (TABNAME).
      WRITE: / WA-ID, WA-NAME.
    ENDSELECT.

  • Select MAX(BUDAT) from ztab (custom table) where... NOT work!

    We use the following statement where BUDAT is one of the fields in our custom table ztab:
    Select MAX(BUDAT) from ztab (custom table) where...
    When activating the above code, get the following error:
    "Unknown column name "MAX(BUDAT)". not determined until runtime, you cannot specify a field list."
    How to resolve this problem to get a max value of the field BUDAT in custom table ztab (it's not an internal table)?
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 10, 2008 3:56 PM

    HI,
    Tyr having a space after and before BUDAT.
    ( BUDAT ).
    Hope it helps,
    Shreekant

  • HT3702 can i download free content from itunes and app store without any billing information?

    I am a iPhone 3gs user firmware version 3.1.3 . the question is can i download free content from itunes and the app store without billing info ? please help !

    If you only want the free apps, take a look here:
    http://support.apple.com/kb/HT2534
    Read the steps carefully as the order in which you follow them is  critical. Note that you can do this only when creating a new Apple ID. You cannot use an existing ID. 
    You will of course not be able to get anything other than the free apps without entering in some sort of payment method (credit card, prepaid iTunes card, gift certificate, etc.)
    Regards.
    Forum Tip: Since you're new here, you've probably not discovered the Search feature available on every Communities page, but next time, it might save you time (and everyone else from having to answer the same question multiple times) if you search a couple of ways for a topic, both in the relevant forums and in the Apple Knowledge Base, before you post a question.

  • I am getting a content protected error that won't allow my downloaded HD content from iTunes to play on my macbook air!  help, please

    I am getting a content protected error that won't allow my downloaded HD content from iTunes to play on my macbook air!  help, please

    This may seem obvious, but presumably you have authorized the MacBook Air in iTunes?

  • Deleteing the contents from the database table

    The aim of this code is to delete the whole contents from these 12 tables.  Is there any way to write the code more efficiently.
    TABLES: ZFFMCTL_AP, ZFFMHDR_AP, ZFFM_CHANGE_LOG, ZFFMDTL_AR, ZFFMHDR_AR,        ZFFMDTL_JV, ZFFMHDR_JV, ZFFMDTL_SKF,ZFFMHDR_SKF,ZFINVOICE_DETAIL,       ZFFMMASTER, ZFFMLOGREAD_CLUS, ZFFMCTL.
    DELETE ZFFMCTL_AP.
    IF SY-SUBRC = 0.
       DELETE ZFFMMHDR_AP.
       IF SY-SUBRC = 0.
          DELETE ZFFM_CHANGE_LOG.
          IF SY-SUBRC = 0.
             DELETE ZFFMDTL_AR.
             IF SY-SUBRC = 0.
                DELETE ZFFMHDR_AR.
                IF SY-SUBRC = 0.
                   DELETE ZFFMDTL_JV.
                   IF SY-SUBRC = 0.
                      DELETE ZFFMHDR_JV.
                      IF SY-SUBRC = 0.
                         DELETE ZFFMDTL_SKF.
                         IF SY-SUBRC = 0.
                            DELETE ZFFMHDR_SKF.
                            IF SY-SUBRC = 0.
                               DELETE ZFINVOICE_DETAIL.
                               IF SY-SUBRC = 0.
                                  DELETE ZFFMMASTER.
                                  IF SY-SUBRC = 0.
                                     DELETE ZFFMLOGREAD_CLUS.
                                     IF SY-SUBRC = 0.
                                        DELETE ZFFMCTL.
                                     ENDIF.
                                   ENDIF.
                                 ENDIF.
                              ENDIF.
                           ENDIF.
                        ENDIF.
                    ENDIF.
                 ENDIF.
               ENDIF.
            ENDIF.
         ENDIF.
    ENDIF.
    This is very urgent,
    Thanks in advance
    John

    Hi ,
    One more thing , Deleting conents of all table in single Loop may cause program .
    This depends on How much data you have in you Table . IF the data is Huge you can split the tables to be deleted . Check for Entry Exists in Table , if not go for Deletion  in the same pre-requisite order.
    Regards,
    sudhi

  • Downloading an image from a remote table via dblink

    Hi
    I am building an Apex 3.0 app that will access data remotely, via a database link. One of the tables has a BLOB column, that I need to display in the app as an image (in a single-record form page) and allow the user to update it as well, uploading a new image if required.
    As it is not possible to select blobs over a dblink, but it is ok to insert/update them, I was planning to:
    - insert the blob into a local temporary table which would have only one column ("image")
    - select from the local table to get a reference to the blob and do the usual stuff to download it to the client
    Though this might work, it seems a bit inefficient to me. Is there any other way to do this?
    Thanks,
    Luis

    http://developer.apple.com/Documentation/Cocoa/Conceptual/URLLoadingSystem/URLLo adingSystem.html

  • HT3951 how do i re-download deleted content from itunes?

    I was using itunes from my PC and accidently deleted some content that I wanted to keep. I was trying to download to PC to make room on my Ipad but didn't see the Download all button at the bottom, till after. Have tried to go into my itunes account to look for deleted content but it shows nothing. Hopefully I don't have to pay or purchase again but please let me know what I can do. 

    Downloading past purchases from the App Store ... - Apple - Support

  • Migrating Content from a Custom ASP Page to a SharePoint Page Layout. Includes object tags to flash CSS images

    Hi Guys,
    I'm currently getting issues when trying to migrate content from ASP Pages used in a custom intranet developed by a client to SharePoint Pages.
    My current strategy to do so is as per below:
    a. Create ASPX Pages in Page Library with SharePoint Designer
    b. Copy all common resource files needed by the pages within the Pages library. Includes folders for Javascript, CSS, images etc. This way relative address of resources in pages will pick up pages library as default folder
    for resources.
    c. Copy Source Code of Page from Browser by right-clicking ‘View Page Source’/ Copy code from .asp file
    d. Clean the code to remove unnecessary codes from SharePoint Pages.
    At this point page renders without SharePoint Branding.
    However if I apply SharePoint Master Page onto the ASPX page by using Style > Attach > Default Master Page, this generates an Error when the page renders.
    What is missing in this approach or what would be the best approach to migrate the page to SharePoint without code solution?
    Grateful if you could help.
    Thanks 
    Rhyan.

    Hi Rhyan,
    As I understand, you want to create a custom application page in SharePoint 2013.
    If you copy the code in the asp page to aspx page, it cannot work. You should write the new code that can work in the asp file for the SharePoint aspx page.
    There is a similar case:
    https://social.technet.microsoft.com/forums/sharepoint/en-US/0a97820a-59b9-4430-a98c-d2941803c38e/classic-asp-pages-to-sharepoint-pages-migration
    You can create a web application page in the visual studio. You also can explicitly change which master page is used by the application page by setting the MasterPageFile attribute of the application Page element. (For example: MasterPageFile="~/_layouts/applicationv4.master").
    The articles below are about creating application Pages for SharePoint.
    https://msdn.microsoft.com/en-us/library/ee231581.aspx
    http://nikpatel.net/2012/01/20/custom-sharepoint-pages-site-pages-vs-application-pages/
    Best regards,
    Sara Fan
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Download clob contents from function instead of a blob column in a table

    I found some examples how to create a download link for data stored in a blob column. However my data is not stored in a blob column but is created in a function returning a clob. Obviously this function can be used to fill a blob column that can then be downloaded but maybe there is a more direct route.

    Hello Rene,
    I adapted one of my snippets for download-links for your case. The procedure is pretty much the same like the one concerning an existing blob. To provide the download, you need to convert your clob into a blob, which can be done easily by using the corresponding function provided by the [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm]DBMS_LOB-API.
    The result might look like the following (untested) code snippet:
    CREATE OR REPLACE procedure download_from_function (p_func_argument IN VARCHAR2, p_filename IN VARCHAR2)
    AS
      l_http_response  UTL_HTTP.resp;
      l_blob           BLOB;
      l_raw            RAW(32767);
      l_length         INTEGER;
      l_dest_offset    INTEGER := 1;
      l_src_offset     INTEGER := 1;
      l_lang_context   INTGER := DBMS_LOB.DEFAULT_LANG_CTX;
      l_warning        INTEGER;
    BEGIN
      -- Initialize the BLOB.
      DBMS_LOB.createtemporary(l_blob, FALSE);
      -- replace the function call for src_clob
      DBMS_LOB.convertToBlob( dest_lob     => l_blob,
                              src_clob     => your_clob_function(p_func_argument),
                              amount       => DBMS_LOB.LOBMAXSIZE,
                              dest_offset  => l_dest_offset,
                              src_offset   => l_src_offset,
                              blob_csid    => DBMS_LOB.DEFAULT_CSID,
                              lang_context => l_lang_context,
                              warning      => l_warning);
      l_length := DBMS_LOB.getlength(l_blob);
      -- create response header
      OWA_UTIL.mime_header('text/plain', false);
      -- add furhter header attributes
      htp.p('Content-length: ' || l_length);
      htp.p('Content-Disposition: attachment; filename="' || p_filename || '"');
      -- close the headers
      OWA_UTIL.http_header_close;
      -- download the BLOB
      WPG_DOCLOAD.download_file( l_blob );
      -- release BLOB from memory
      DBMS_LOB.freetemporary(l_blob);
    EXCEPTION
      WHEN OTHERS THEN
        DBMS_LOB.freetemporary(l_blob);
        RAISE;
    END download_from_function;
    -- Page process before header on blank page
    BEGIN
      download_from_function (p_func_argument => 'your_argument_for_your_clob_returning_function',
                              p_filename => 'filename_for_download.txt');
    END;You should change function name and arguments to fit your clob-function's signature. You may also want to add a characterset conversion if needed. See the [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm]API-doc for details.
    -Udo

  • Open BLOB Content from an Interactive Report in a New Window

    Hi All,
    I have an Interactive Report with the following query:
    SELECT ID,
      FILE_NAME,
      FILE_MIME_TYPE, 
      FILE_CHARACTER_SET, 
      DBMS_LOB.GETLENGTH(FILE_CONTENT) FILE_CONTENT, 
      FILE_LAST_UPDATED 
    FROM FILESThe Number/Date Format property for the FILE_CONTENT column is as follow:
    DOWNLOAD:FILES:FILE_CONTENT:ID::FILE_MIME_TYPE:FILE_NAME:FILE_LAST_UPDATE:FILE_CHARACTER_SET:attachment:DownloadWhen I click on the FILE_CONTENT link in the report, depending on the type of file, it opens in a new window or in my report’s window.
    I am trying to set the link to always open the content in a new window. I tried changing the Link Attributes to target="_blank" but it did not work.
    There is an example in the Package Application “Sample File Upload and Download” on apex.oracle.com. Page 1 has a report that allows you to add files. You can add files such as PDF, SQL, or TXT file in order to replicate my situation.
    I appreciate any help!
    Thanks,
    Erick

    The problem is solved!
    Apparently the Content Disposition: Attachment in the BLOB Download Format Mask does the trick.
    For some reason I have to logout and login again in the application to see the change.
    I tried changing the Content Disposition to Inline and then back to Attachment, and the file keeps opening in the same window unless I start a new session.
    Is there any explanation why it is working that way?
    Thanks!
    Erick

  • How to download a file from a custom server location?

    Hello experts,
    I have the following scenario:
    A BAPI creates an .exe file and stores it in a custom folder in the server where the portal (and my WD application) is running. This happens once a day.
    What I need to do is create a link or button (doesn't matter) so that users can click on it and download this file.
    I already checked the file upload - download tutorial (http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081257f;jsessionid=%28J2EE3417500%29ID0774236150DB11016171821629714331End?overridelayout=true) however this one considers the file to be downloaded is stored in the src folder of the project, thus it doesn't really help me.
    How can I achieve this? Any suggestions and help will be greatly appreciated.
    Thanks!

    hi Alain,
    Use File API to read data from the file. It will return byte array from the file. Set Byte array to the file resouce context attribute.
    bind this attribute to the filedownload UI element.
    Since you need to read file from the same server where webdynpro application is running, You can give the folder path on the server where the file is located.
    try {
                   File inputFile =
                   new File("C:\\Test\\Test.txt");
                   FileInputStream in = new FileInputStream(inputFile);
                   byte b[] = new byte[ inputFile.length()];
                   in.read(b);
                   in.close();
              } catch (FileNotFoundException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
              } catch (IOException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();

  • ABAP Program to delete the WDSO contents from active data table & Manage Re

    Hi,
    We have requirement where we have to delete the request id from manage screen and data from Active table of WDSO.
    I have gone through this weblink where we have to hardcode the DSO name in the table (Deletion of WDSO (Write-optimized DataStore object) Load requests and active table data without deleting it from targetSAPNetworkWeblogs%2528SAPNetworkWeblogs%2529)
    Apart from that is there any suggestions or input where i can have selection screen for DSO and execute that will help us to delete the Request IDs and content of active table from WDSO.
    Suggestions or input programs really appreciated.
    Kindly do the needful.
    Regrads,
    Prem
    Edited by: pannalde on Nov 22, 2011 8:24 AM

    Hi,
    http://help.sap.com/saphelp_nw04/helpdata/en/2d/677b3c513d3311e10000000a114084/content.htm
    With program RSSM_DELETE_WO_DSO_REQUESTS it is possible to delete old requests in the Write-Optimized DSO, exactly like we are used to do with PSA requests via a Process Chain.
    This program is available as of SAP NetWeaver BW 7.01 SP07. See note 1437407 for details.
    You can automate the deletion of old WO requests by using the ABAP program step in the Process Chain.
    Regards,
    rvc

Maybe you are looking for

  • Share Photos on the same iMac with different user accounts... How do You???

    Hello, I was wondering if there is a way to share photos with another user (same computer, different log-in names) on the same iMac? There are two users on my iMac and I want to be able to share photos and other documents, music etc. with them, but c

  • Why does eLearning for PC not install when Presenter is included in the package?

    I have downloaded eLearning from the Adobe LWS site, ran AAMEE 3.1 to create a 64 bit package.  When I try to install the package with Presenter included the install process appears to be working.  I can see the programs are being installed but at th

  • Reverse Geocode function accuracy...

    Hello everyone I have Oracle 10g R2 on windows. The setup is as follows: a GPs device sends data ( longitude/latitude )to a table (LOG) and I need to reverse code the coordinates. in another table (GEOCOD4) I have addresses associated with lat/long c

  • ITunes 7 not even opening

    I tried to upgrade my PC's iTunes from 6.0.3 (I think) to 7.0.0.1 (or whatever the version is); it seems to have installed fine but when I try to open iTunes, it gives me the Software License Agreement, and after I agree to the terms, 'The iTunes app

  • Enterprise Compliance Report not showing any Pc

    I've MBAM going for a day or to, i can see computers in the computer compliance report if I type the test computers in; however, i dont see any computers under the Enterprise Compliance Report. i am running mbam 2.0 sp1 on 2012, and sql on server 08