Download content clob of function instead of a blob column in a table

I found a few examples of how to create a download link data stored in a blob column. However my data are not stored in a blob column, but are created in a function that returns a clob. Of course, this feature can be used to fill a blob column, which can then be downloaded but there may be a more direct route.

Hello René,.

I adapted one of my snippets for the download links for your case. The procedure is much the same as that concerning an existing blob. In order to offer the download, you must convert your clob in a blob, which can be done easily by using the corresponding function provided by the [http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm url] 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 must change the function name and arguments to fit your clob function signature. You can also add a characterset conversion if necessary. See the [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm] API - doc for more details.

-Udo

Tags: Database

Similar Questions

  • Downloading files from the blob column

    Hello

    I had the file it is implemented for the database blob column using the document below:
    http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html#85

    Now can someone please tell me how to download or view the file from the database blob column?
    I use jdev 11

    Thank you

    Hello

    At the end of your download method invoke:

    ActualExceptionIter.executeQuery ();

    Kuba

  • Download blob function instead of table field

    Hello
    Is it possible to download the content of blob field that are returned by a function?
    I can only download blob if the blob is in the column of the table...

    Thank you

    Vincent

    Hi Vincent,.

    I think you can download the blob content returned by a function with no problems. In the example below, the get_blob function returns a BLOB, you must specify the name and the mime type and the length of the BLOB is obtained using DBMS_LOB. GETLENGTH. Finally, a call to the wpg_docload.download_file procedure is made. To call the procedure download_file, you can do it through the URL or on a page with a 'branch at PL/SQL procedure' in the point "before Header". More info on 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;
    

    Kind regards

    Sergio

  • Download given clob in file

    Hello
    Does anyone know if Apex manage clob as the way it handles the blob?

    I have a clob column in a table and I want to have a download link in the report of the apex for the user to download the content to a file... It is possble?

    Thank you

    This section of the documentation Table of custom download of Documents for examples of code etc.

    Do some modifications, convert the clob to a blob, use the API of wpg_download it contains, set headers, etc.

  • Cannot download mp3, it play mp3 instead of downloading

    Cannot download mp3, it play mp3 instead of downloading.

    below is the link to test your

    FTP://www.AMTB.jp/MP3/02/02-040/

    previous version works perfectly, download smoothly.
    Appreciate back to previous versions.

    Thank you
    Ho

    Hello, CMC,

    Thanks for posting about Mozilla Support. We value and appreciate as a user.

    How do you normally download your use out there? You hold the key on the mp3 then save them? Or do you just rely on them?

    Thank you!

    Did you know that Mozilla Support is aided by volunteers? Be part of SUMO! http://MZL.la/OJtpch
    Make a donation of more than $30 and get a T-Shirt! https://donate.Mozilla.org/page/contribute/joinmozilla

  • downloadable content purchased recovery (long)

    There are long (about 8 years ago), I had my xbox 360, and my wife and I played all kinds of downloaded content, we have obtained. less than $ 100 us. now that all the emails went. and I find myself in a frustrating situation, I just bought my son for his 6th birthday and now my wife and I feel nostalgic and want to come back all these Games Arcade to the cheese. but now, they are expensive. So how the hell do these purchases, the customer service was not able to help that the emails are no longer used, but I have no gamertags. I'm screwed in that they all delete after 60 days, or is there still hope?

    It is stored in the account by email address, so as long as you can remember your e-mail address, password and log on to www.xbox.com using this email/password, then all your purchases will be always be there waiting for you.

    If you have forgotten your password, use the password reset page here.

  • Book audio downloads more drive Media Console instead of going in addition to drive Media Console goes to Open Office Writer

    Original title: I joined my library and downloaded media player console to allow me to download the library audio books.but audio books go in my Office Open writer.why is this, that I can do.v

    I joined my library-Line.and downloaded on my computer, A player more Media Console.Which allows me to download Audio books from the library... The first Audio book I download. And I could play it. Well, two days later downloaded another Audio Book and instead of going in my drive Media Console .it on my Open Office Writer, which is not good. Please you can Help.What what I need to do to put this problem Right.Thank you for reading this. Waiting for your response.

    Hi Bobdunford,

    You must check with the vendor of the application in this regard.

    http://www.overdrive.com/contact/

  • Hello! I ve bought PS elements 12 for windows. Now, I changed to use an iMac. How can I download items 12 for Mac instead?

    Hello! I ve bought PS elements 12 for windows. Now, I changed to use an iMac. How can I download items 12 for Mac instead?

    Normally an older version of the PSE has a license that is good for both platforms, just so install the Mac version and use the serial number, you already have.

    Download and Installation Help-

    https://helpx.Adobe.com/download-install.html

    PES 10, 11, 12, 13, 14 - https://helpx.adobe.com/photoshop-elements/kb/photoshop-elements-downloads.html

    You can also download the demo version of the software through the page linked below and then use your current serial number to activate it.

    Don't forget to follow the steps described in the Note: very important Instructions in the section on the pages of this site download and have cookies turned on in your browser, otherwise the download will not work correctly.

    Photoshop/Premiere Elements 12: http://prodesigntools.com/photoshop-elements-12-direct-download-links-premiere.html

  • The content was not downloaded.  Cannot download content for article in PÉCS. [IN021]  Select download to try again.

    When I want to download my own article HTML (exported with the WordPress PlugIn, packed with HTML Article Packager) I get this error:

    ---

    The content was not downloaded.

    Cannot download content for article in PÉCS. [IN021]

    Select download to try again.

    ---

    I see I am not alone with this error:

    Re: Download error

    Is there a solution? What I am doing wrong?

    Thank you

    Ulrich haha

    Hello

    Are there empty files in the exported HTML file? A link to the HTML exported to [email protected] please

  • Delete downloaded content

    Hello

    is there a way to show the content uploaded within the app? And is it possible to delete the selected items?

    Thank you!

    Lars

    Lars salvation,

    Automatically, we manage the downloaded content and will remove older read articles that we need to free up space. There is no user interface to manage this for the moment.

    Neil

  • When I installed my product, the back of the box says allow 5 GB for downloadable content? What downloadable content and where can I find it?

    Anyone know where I can go to get the downloadable content?

    In Expert Mode, there is a graphics library. Thumbnails for the downloadable models have a blue corner. Once you click to use a particular graphic in your design, it will download locally to your machine. If you also have video editor (Premiere Elements) it has usually content to download for example templates to make instant film.

  • Download Card purchased. System Windows 8 32-bit who refuse installation (64-bit only). There he possibility to download a 32-bit version instead of the version 64 bots? Thank you

    There he possibility to download a 32-bit version instead of the version 64 bots? Thank you

    You have not indicated what software it is, but if it's something to do with the Creative Cloud software there is no 32 available bits.  All CC programs require 64-bit systems.

  • Permissions to download content for the contents of shared folders

    Full administrators can download content to the shared folders of content? All the documents I can find says that only the author can, but in practice, we find that full administrators can also download content for folders as well.

    Is this true for anyone else?

    Admins can do anything except content download and host meetings during the use of the license for the meeting of the named host. You must be a member of the authors or host the meeting of groups to download items to the content library.

  • Download content after publishing an event

    I want to publish an event that I've created, but I do not have my ready to download content. Can I download the presentation once the event has been published? I won't hold my registration while I am preparing the presentation.

    Post edited by: ashish gupta. to add a more meaningful topic title

    Hello

    You can change the associated content for an event after event published.

    Steps to change the associated content of an event-

    1. go on the page about the event of this event

    2. click on the link "select content".

    3. Select the appropriate content

    4. click on the button Save.

    Thank you

    Vikash Acharya

  • How can I apply the downloaded content from Adobe first Elements 10?

    How can I apply the downloaded content from Adobe first Elements 10? I have download all content in a file called AllContent1 (2.95 GB) file. Everytime I open Adobe first items 10, a pop-up box appears saying that "a small set of content (Flash movies, titles and menus templates themes, etc.) has been installed.» You can install all the content by inserting your DVD content or download. You want to install now? YES/NO? I have also subscribed to $49 for 20 GB of storage, which makes me a member over a year. Any help would be appreciated thank you very much.

    -MirzaO

    MirzaO wrote:

    How can I apply the downloaded content from Adobe first Elements 10? I have download all content in a file called AllContent1 (2.95 GB) file.

    Download a two files. A small end .exe, the other .7z, wide, fine. You must run the small .exe file and will decompress the .7z big file to the correct locations.

    See you soon,.

    --

    Neale

    Insanity is hereditary, get you your children

Maybe you are looking for

  • Sierra / Mac Adware Cleaner

    Since I've upgraded to the new OSX on my iMac, what an advertising program keeps popping up whenever I log on my computer. I tried to remove it, but it always comes back. It is very inconvenient for my mac was going well until I upgraded. What is c?

  • Satellite L300-1AQ - Fan switches do not properly under Linux

    For L300-1AQ, the CPU fan is controlled by the BIOS. When you start the Linux machine against the cold, the fan runs at least as it should. But then nothing happens until the critical temperature is reached. At this point, the CPU fan going at maximu

  • Wuauclt.exe pigs all time processor which makes the computer unusable

    The machine is a laptop Dell Vostro 1000 with Win XP SP3 Home edition. It has 2 GB of RAM with a 120 GB hard drive that is half full. The computer initially had no protection against the virus, then McAfee and Norton now. The problem exists all along

  • Laptop power light blinking and won't turn on

    I have a laptop HP Pavilion 1045DX M6 and I recently tried to plug it into a screen RGB, analog and I saw a spark and the laptop off. During this time, I ran the laptop directly from the adapter without battery because I don't really use it. If the l

  • 80090000B error code

    Hey Microsoft, So my computer could not install Windows 10 and now when I try to install again I 80090000B error code every time. I tried Googling the error code but their doesn't seem to be a lot more on this subject. I hope I can still get Windows