How to use UTL_FILE to print a JPG image in a CLOB

I'm using Oracle 11.g.  I have an Oracle Apex application that generates automated emails. In the Apex, the user inserts a JPG image in a rich text field. This image is stored in a CLOB field. When it's time to send emails, Apex calls a stored procedure that reads the JPG image and stores it in a local variable called l_image_clob. The procedure of sending the embedded image with the rest of the body by e-mail to a list of users. (Note: this an embedded image and it is not an attachment). It all works very well.

Now, I try to save the JPG image content stored in the l_image_clob variable in a JPG file on the server. The server is located on a Windows 7 platform.  The following code generates a file named correctly and the size of the file is correct, but it is not readable by the system. I get the error "is not a valid bitmap file" when I try to open it with Microsoft Paint. The image in the clob data looks something like: / 9j/4AAQSkZJRgABAgEAZABkAAD/4RXaRXhpZgAATU0AKg (a bunch more data) SSSSUpJJJJSkkkklKSSSSU / / Z

How do I use utl_file to save the JPG image bank in the l_image_clob variable to a valid JPG file?

-- Here's the code which creates the file that is "not a valid bitmap file"
  -- Create a file based on the content of l_image_clob
  l_image_filename := 'image_' || p_event_pkey || '_' || i ||
  '.' || l_image_ext;
  l_file_handle := utl_file.fopen(l_dirname , l_image_filename, 'wb');
  -- wb is write byte. This returns file handle
  <<inner_loop>>
  for i in 1 .. ceil( length( l_image_clob ) / chnksz )
  loop
  utl_file.put_raw( l_file_handle,
  utl_raw.cast_to_raw( substr( l_image_clob, (i-1) * chnksz + 1, chnksz )));
  utl_file.fflush(l_file_handle);
  end loop inner_loop;
  utl_file.fclose(l_file_handle);

procedure clobbase642file (p_clob clob, p_dir varchar2, varchar2 p_filename)

is

t_buffer varchar2 (32767).

number of t_pos: = 1;

number of t_size: = nls_charset_decl_len (32764, nls_charset_id ("char_cs"));

number of t_len;

t_fh utl_file.file_type;

Start

t_fh: = utl_file.fopen (p_dir, p_filename, "wb", 32767);

t_len: = length (p_clob);

loop

When the t_pos output > t_len;

t_buffer: = replace (replace (substr (p_clob, t_pos, t_size), Chr (10)), Chr (13));

t_pos: = t_pos + t_size;

all in t_pos <= t_len="" and="" mod(="" length(="" t_buffer="" ),="" 4="" )="">0

loop

t_buffer: = t_buffer | Replace (replace (substr (p_clob, t_pos, 1), Chr (10)), Chr (13));

t_pos: = t_pos + 1;

end loop;

UTL_FILE.put_raw (t_fh, utl_encode.base64_decode (utl_raw.cast_to_raw (t_buffer)));

end loop;

UTL_FILE.fclose (t_fh);

end;

Tags: Database

Similar Questions

  • How to use a shared printer on XP on Win 7?

    I print on CD for a machine to Windows XP SP3 by using the Epsons Print CD employees. I recently installed a bigger HD, more memory and Win 7 Ultra 64 Bit N I have disabled the firewall on the computer of my Win 7 (temporarily) that allowed me to 'add printer' via IP.addr/sharename. I'm invited to the paswsword username, which I go without any problems. Next Win 7 search the printer driver. Since the XP machine doesn't have the driver for win 7 64 bit, it fails, check the update of the victory and ends by asking me to provide the *.inf file. I don't have any idea what inf file, he would like to see.

    See if Epson has a Windows 7 compatible driver on their web site.  Install it and it should allow you to specify a printer connected to the network. Brian Tillman [MVP-Outlook]

  • Flex 3: how to use the trace print data in the console

    Hello

    I heard that we can use trace to print data on the console in Flex Builder 3. But when I try, it's of no luck.

    Below is a simple program, in which I was out of luck.


    public function callMe (): void
    {
    trace ("AAA");

    }

    < mx:Button id = 'Save' name = 'Save' label = "Save" height = "23" click = "callMe ()" / >

    Here in the porogram above, after you have clicked on the button, I can't see 'AAA' related inside my Flex Builder.

    Any help?

    Thank you.

    Hi Kiran

    Made a breakpoint to the line of trace and debug the application you can find the message u typed in the console... trace works only in debug mode... not in development mode...

    Good day

    Thank you

    RAM

  • How to use HP t790ps printer wireless connectivity

    Original title: how to connect the wireless network connectivity to my identity as a product t790ps priter has CZ 154A ID we 20 162529

    PLEASE SEND MY ANSER BY E-MAIL.

    Hello

    What version of OS are you using?

    View printers wireless section in the site mentioned below:

    Getting started with printing

    http://windows.microsoft.com/en-PH/windows7/Getting-started-with-printing.

    You can get the driver for the printer on the site mentioned below:

    http://h20000.www2.hp.com/bizsupport/TechSupport/DriverDownload.jsp?prodNameId=5053927&lang=en&cc=us&taskId=135&prodTypeId=18972&prodSeriesId=5053926.

  • How to use CAlert to print an object.

    I have a block of code as below:

    InterfacePtr<ITextFocus> iSelectionTextFocus(iTextFocus, UseDefaultIID());
      if (iSelectionTextFocus != nil){
      focusStart = iSelectionTextFocus->GetStart(nil);
      }
    
    
    
    
      InterfacePtr<IGTTxtEdtSnapshotInterface> iGTTxtEdtSnapshotInterface(iDocument,UseDefaultIID());
      if (iGTTxtEdtSnapshotInterface == nil || focusStart == kInvalidTextIndex){
      break;
      }
      iGTTxtEdtSnapshotInterface->SetStoryAndIndex(storyUIDRef,focusStart);
      TRACEFLOW(kGTTxtEdtPluginName,"Text story observer range == %d\n", focusStart);
    

    From the code, I want to o print 'focusStart' using CAlert::InformationAlert. But I got error when you try to write a line like this:

    CAlert::InformationAlert(focusStart);
    

    How can I solve this problem?

    Note: The code block is to get the file 'GTTxtEdtStoryObserver.cpp' in InDesgin SDK under the project 'gotolasttextedit '.

    Kind regards

    Tri Dung

    I use these lines of code to make things:

    std::string tempString("Text has changed at index: ");
      std::string index(std::to_string(focusStart));
    
      PMString message(tempString.c_str());
    
      message.Append(index.c_str());
    
      CAlert::InformationAlert(message);
    

    This problem is solved!

    Kind regards

    Tri Dung

  • How to use Gallery of filters on an Image that I made from photoshop?

    So I edited this image of me on Photoshop basically I used the quick selection tool and then just back up my car and stuck on a transparent background and now I want to use in Illustrator and kind give as a funky look, you know as ocean waves or charcoal you know something like that but it wont let me it please help?

    in illustrator, you must track of images > photo high fidelity > expand first

    You can then use the effects

    or in photoshop, something like

    Image > adjustment > reverse

    image > adjust > curves to darken the face more

    Select background, and then apply a gradient orange

  • How to use icons to start an animation (image sequence)

    Hello

    I find the way to do that with slide show, State of multiple objects,... but can not find with what I call an animation (image sequence).

    Any idea please?

    Thanks in advance!

    The sequence of images on a MSO and set the AutoPlay sequence. Blow up a button in this state of ASM.

  • How to import files from RAW and jpg formats

    If I shoot in RAW + JPG format images, there are two files for each image (a RAW and a JPG).  When I import into LightRoom, only the RAW files appear on the screen to import.  To import the JPG file, I need to download the jpgs from the card to the computer and then separately to import computer jpg files into LightRoom.

    How can I get the RAW and JPG images formats appear in the import window?  I have an iMac, import images from the card via a card reader and use LR CC 2015.

    In your Lightroom preferences, there is an option to treat JPEG files next to raw separate image files. If you check this option, then Lightroom will import JPEG images, but also raw images. Once you select this option you can synchronize files that have already been imported and JPEG images will be added to the catalog.

  • How to use the capture and the print button

    I tried to figure out how to use the capture and the "print" button, or add or what you call. I press it and the whole page of a different color changes, so I try to cut the section I want but I don't know how to send it to the printer. Can someone help me with this. I'm not at savvy with tech stuff, but when I find a recipe or something and it doesn't have an option to print a certain area, I can't understand how to use it?

    Thank you

    Andi Starbuck

    That happens to me is, I click and drag to make a rectangle of yellow selection, and as soon as I raise my finger on the mouse button, the part I've selected is captured as an image, a new tab opens and preview before printing, the image display. I can use the installation of the Page or simply print. But if I close the preview, this temporary image vanishes and I'm back on the page where I started. You see something different?

  • How to use the Print Screen function?

    I've seen various descriptions of how to use the print screen function.

    It would be nice to actually tell one that works.  None have worked for me.

    [Fn] and Prt SCr does not work.

    CTRL and Prt SCr does not work.

    CTRL, Alt, and Prt SCr does not work.

    [Fn], Ctrl and Prt SCr does not work.

    If anyone knows the correct method to activate the screen capture function which would be a good thing.

    From the looks of things, HP has a big problem with this function.

    Here's a microsoft articleon the use of the screenshot function.

    This should answer your questions.

    Thanks for taking a peek.

  • Does anyone know how to use the HP Deskjet F4580 wireless printer

    Does anyone know how to use the HP Deskjet F4580 wireless printer

    Do you have a specific question or just general knowledge?

    The manual is available online here.

  • How to use omly black ink on my printer?

    I have a brother mfc-j410w. How can I configure it to use black ink only?

    Please go here:

    http://welcome.solutions.brother.com/BSC/public/EU/GB/en/doc/manual_index.html?reg=EU&c=GB&lang=en&prod=mfcj410_all&dlid=&flang=English&type2=-1

    Then download the software user's Guide*-on Page 12, you will see how to select grayscale to print in black and white.

    If you do this because your color cartridge is empty so not all printer software will allow you - it can insist that there is a current non-empty color cartridge. Test it by trying or contact the support of brother for advice:

    http://www.brother.co.uk/g3.cfm/s_page/204620 .

    * This is for the MFC J410 (the closest model you number I could find) the MFC-J410w.

  • No matter what kind of program that I use or what printer I print on, my PC has produced a preview before print screen every time I click on print. Anyone know how to disable this option?

    No matter what kind of program that I use or what printer I print on, my PC has produced a preview before print screen every time I click on print. Anyone know how to disable this option?

    It doesn't seem to be anything the given that this happens no matter what printer print on the printer. Any program, I use the same thing also happens.

    Hello

    Apart from the valubable solutions provided, I suggest that you post your question on the TechNet Forums as it appears, it comes to your work computer.

    Windows XP IT Pro

    Thank you.

  • As of today, I entered a withdrawal check in Microsoft Money and used the option print. It doesn't then gives the option 'Print cheques' as he has always in the past. How do I print the failure?

    Today, I went in a transaction of withdrawal in Microsoft Money 2005 and used the option 'print '. It does not have the option 'Print cheques' as he has always in the past. How to print the check now?

    Support for MS Money ended on January 31, 2011...

    01/31/2011: the end is near! If you have not already meditated it, now may be a good time to start... (01-jan - 11 & ff)
    http://social.Microsoft.com/forums/en/money/thread/2a40ad46-2258-4637-8941-9a1dc9a624aa

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    You will find support remaining (as it is) for MS Money in this forum: http://social.microsoft.com/Forums/en/money/threads

  • HP Deskjet Ink Advantage 4645: how to use ink printer of Dubai in SG

    How to use my printer who had bought from Dubai to Singapore.

    Could not find the ink cartridge of in SG.

    Here's my printer model

    Printer e-all-in-one-HP Deskjet Ink Advantage 4645

    not produce is as below

    B4L10C

    INK CARTRIDGE NO. 650

    Hello

    Singapore (Asia Pacific), it uses 678. Now, please follow the instructions below to call HP and they will tell you how to reset it with a secret code:

    http://support.HP.com/us-en/document/c02558798

    Kind regards.

Maybe you are looking for

  • Modify the html code in the page you are viewing automatically

    How to change automatically certain code of html on certain web pages in firefox As on the Web pages, I can right click inspect element and it will allow me to remove things off the page. I want that to happen automatically for certain Web pages when

  • Import custom a6300 LUT?

    Is it possible to add your own LUT custom to use as a monitor of gamma function help during the recording of the sequences in the a6300? Currently, I use the Auto display Gamma function help, but wonder if I can watch with my own. Thank you!

  • Equium A60 freezes when I insert a disc into the CD-ROM drive

    Hello I have a problem with my CD drive - whenever I put a disc in it freezes the computer laptop everything! I can't do anything that even the mouse pointer hangs on the page. I have to close the whole pc and start again - what is happening again an

  • Satellite P100-253: how to activate speaker lights

    Hello there... I read some post inherent who refers to blue LED light under the speaker... My question is, there is NO blue LED light in both of my 'speakers', I have a P100-253, so where can I I turn it on? or y at - it no blue LED on this model?

  • Satellite P300D-h-13: Bluetooth no longer works after update BIOS 3.30

    I have a huge problem with my bluetooth module integrated on Toshiba P300D-h-13.It worked great until I have not flashed Bios to version 3.30. Now, I do not see my module and when I start battery bluetooth, it says that I should plug my camera. Plese