How to save pdf file in database

Dear All,
my application is forms 6i and database is 8i,requirement is that how to save pdf file in database and users can view through forms

I'll apologize up front for the length of this post. I have a few database procedures I created that write a file to a BLOB column in a table as well as retrieve the BLOB from the column after it stored there. I have successfully stored many different types of binary file to the database using these procedures - including PDF files. I have not used these procedures in a Form so I can confirm that they will work, but theoretically they should work. I'm including the code for each procedure in this posting - hence the apology for the long post! :-)
Also, since these procedures reside on the database you will need to use Forms TEXT_IO built-in package to write your file to the server before you can use these procedures to store and retrieve the file from the database.
These procedures reads and writes a binary file to a table called "LOB_TABLE." You will need to modify the procedure to write to your table.
-- Author :  Craig J. Butts (CJB)
-- Name   :  load_file_to_blob.sql
--        :  This procedure uses an Oracle Directory called "IN_FILE_LOC".  If you
--           already have a directory defined in the database or would prefer to use
--           a different Directory name, make sure you modify line 21 to reflect the
--           new Directory name.
-- ==================================================================================
-- History
-- DATE        WHO         DESCRIPTION
-- 12/11/07    CJB         Created.
CREATE OR REPLACE PROCEDURE load_file_to_blob (p_filename IN VARCHAR2) IS
   out_blob    BLOB;
   in_file     BFILE;
   blob_length INTEGER;
   vErrMsg     VARCHAR2(2000);
   -- set the in_file
   in_file := BFILENAME('IN_FILE_LOC',p_filename);
   -- Get the size of the file
   dbms_lob.fileopen(in_file, dbms_lob.file_readonly);
   blob_length := dbms_lob.getlength(in_file);
   -- Insert a new Record into the tabel containing the
   -- filename specified in P_FILENAME and a LOB_LOCATOR.
   -- Return the LOB_LOCATOR and assign it to out_blob.
   INSERT INTO lob_table (filename, blobdata)
      VALUES (p_filename, EMPTY_BLOB())
      RETURNING blobdata INTO out_blob;
   -- Load the file into the database as a blob., dbms_lob.lob_readonly);, dbms_lob.lob_readwrite);
   dbms_lob.loadfromfile(out_blob, in_file, blob_length);
   -- Close handles to blob and file
   -- Confirm insert by querying the database
   -- for Lob Length information and output results
   blob_length := 0;
      SELECT dbms_lob.getlength(blobdata) into blob_length
        FROM lob_table
       WHERE filename = p_filename;
      vErrMsg := 'No data Found';
   vErrMsg := 'Successfully inserted BLOB '''||p_filename||''' of size '||blob_length||' bytes.';
-- Author   :  Craig J. Butts (CJB)
-- Name     :  write_blob_to_file.sql
-- Descrip  :  This procedure takes a BLOB object from a database table and writes it
--             to the file system
-- ==================================================================================
-- History
-- DATE        WHO         DESCRIPTION
-- 12/11/07    CJB         Created.
CREATE OR REPLACE PROCEDURE write_blob_to_file ( p_filename IN VARCHAR2 ) IS
   v_blob      BLOB;
   blob_length INTEGER;
   out_file    UTL_FILE.FILE_TYPE;
   v_buffer    RAW(32767);
   chunk_size  BINARY_INTEGER := 32767;
   blob_position INTEGER := 1;
   vErrMsg     VARCHAR2(2000);
   -- Retrieve the BLOB for reading
      SELECT blobdata
        INTO v_blob
        FROM lob_table
       WHERE filename = p_filename;
      vErrMsg := 'No data found';
   -- Retrieve the SIZE of the BLOB
   blob_length := DBMS_LOB.GETLENGTH(v_blob);
   -- Open a handle to the location where you are going to write the blob
   -- Note:  The 'WB' parameter means "Write in Byte Mode" and is only
   --          available in the UTL_FILE pkg with Oracle 10g or later.
   --        USE 'W' instead for pre Oracle 10q databases.
   out_file := UTL_FILE.FOPEN('OUT_FILE_LOC',p_filename, 'wb', chunk_size);
   -- Write the BLOB to the file in chunks
   WHILE blob_position <= blob_length LOOP
      IF ( ( blob_position + chunk_size - 1 ) > blob_length ) THEN
         chunk_size := blob_length - blob_position + 1;
      END IF;, chunk_size, blob_position, v_buffer );
      UTL_FILE.put_raw ( out_file, v_buffer, TRUE);
      blob_position := blob_position + chunk_size;     
   END LOOP;  
END;Hope this helps.
-- If my response or the response of another is helpful or answers your question please mark the response accordingly. Thanks!

Similar Messages

  • How to save .pdf file using office word and excel

    Can someone help me how to save .pdf files using office word and excel?  I reinstalled my adobe 7.0 pro in my new pc and before I was able to do it but with my old pc.

    For anything after Office 2003, you have to print to the Adobe PDF printer. If you installed AA 7 on OS newer than XP, you may have to do a workaround to get it to work. With later versions of WORD you can always use the MS plugin for creating PDFs.

  • How to remove a hidden text in pdf file with Acrobat Pro 9. How to save pdf file and remove hidden text?

    I made this file in indesign, the highlited empty spaces indicates that their is a hidden text and it pop up when searching for some words in pdf file. so how can I save pdf file to keep only the seen text ???

    Dear lrosenth,
    I went through some codes/suggestions in internet and I found that I need to have cmap file and cid font file for the respective font since pdf doesn't support unicode fonts directly.
    Can you help me to know where can I get cmap file and cid font file for tamil language font Latha(TrueType) microsoft font.

  • How to save PDF files on an iPad files

    How do I save PDF files onto an iPad?

    There are several common ways to do this:
    1) Email the files to yourself and choose "Open In" from the mail application by long pressing on the attachment(s)
    2) Use a file sharing service like, dropbox, gdrive or skydrive and choose "open in" from those applications
    3) Use iTunes as I describe in response to this thread:

  • How to Save pdf file in the BLOB field in the database

    I have to save a pdf file which is on the client machine to save in the database column of type BLOB. How can i do that?

    LostWorld wrote:
    I have to save a pdf file which is on the client machine to save in the database column of type BLOB. How can i do that?PL/SQL code cannot hack across the network. break into that client machine, and read that PDF file from the client's harddrive.
    There is a very fundamental client-server principle at stake here - the purpose of the client. What is the purpose of the client? Amongst others, it is to interface with the client hardware and peripherals and devices. Like reading the client keyboard and sending that to the server. Or reading data from the sever and rendering it on the client's display device. Or to receive CSV data from the server and writing it to a local file.
    It's purpose is also to read a local file, like a PDF file, and submit that file's contents to the server for storage.
    The following pseudo code explains the basic principle:
      // call oracle to create a LOB
      ExecuteSQL( 'DBMS_LOB.CreateTemporary( .. )' )
      open file( fileHandle )
      while not EOF( fileHandle )
        // read data from the file
        read file( fileHandle, buffer )
        // write this buffer to the LOB in Oracle
        ExecuteSQL( 'DBMS_LOB.writeAppend( .. )' )
      end while
      close file( fileHandle )
      // now tell Oracle what to do with that LOB
      ExecuteSQL( '...' )
      .. etc..Thus the client:
    a) creates a LOB in Oracle via a PL/SQL call
    b) passes data from the client and appends it to the LOB
    c) tells Oracle what to do with LOB, such as inserting it into a table

  • How to save report file to database after generation

    I am generating a report using oracle reports 6i. The report is a .pdf file. I need to save this file in a database table to that i can show a link on the application to view the file online. How can i achieve this functionality?

    Yes you can. Find about BLOB fields.

  • How to save pdf file(path) in oracle db

    Hi all,
    we are using forms 10g. the requirement is user can upload the pdf file from the forms. the pdf file should store in the server folder and the path can store in the db table field. when ever the user wish to download that pdf based up on the unique pdf name that should be open or save on client machine.
    can anybody help me how to do this
    Thank you

    Hi Amatu Allah,
    thank you for your reply
    i have the code based upon the webutil functions but it is not working can u pls help me
    Here---B8 is Block name
    if :toolbar.li_mode in('M') then
         if :b8.pdf_loc1 is not null then          
    l_success boolean;
    l_success := webutil_file_transfer.Client_To_DB_with_progress
    (:b8.pdf_loc1-------------------------------------------------------------------------------------source file location,
    't002pod_pdf', ---------------------------------------------------------------------------------table name
    'pdf',-----------------------------------------------------------------------------------------------column name
    'doc_no = :b8.doc_no',---------------------------------------------------------------------doc_no is field
    'Upload to Database in progress',
    'Please wait',
    if l_success
    message('File uploaded successfully into the Database');
    message('File upload to Database failed');
    end if;
    when others
    message('File upload failed: '||sqlerrm);
         mesg('Plese Select The File name');
         end if;
    end if;
    ---------------------------------------------------------------------WEBUTIL FUNCTION BODY------------------------------------------------------------------------
    FUNCTION Client_To_DB_With_Progress
    ( clientFile in VARCHAR2,
    tableName in VARCHAR2,
    columnName in VARCHAR2,
    whereClause in VARCHAR2,
    progressTitle in VARCHAR2,
    progressSubTitle in VARCHAR2,
    asynchronous in BOOLEAN default FALSE,
    callbackTrigger in VARCHAR2 default NULL) return BOOLEAN is
    return UploadInt
    ( clientFile,
    END Client_To_DB_With_Progress;
    -- Internal implementations ----
    FUNCTION UploadInt ( clientFile in VARCHAR2,
    spec1 in VARCHAR2,
    spec2 in VARCHAR2,
    spec3 in VARCHAR2,
    toDB in BOOLEAN,
    withProgress in BOOLEAN,
    progressTitle in VARCHAR2,
    progressSubTitle in VARCHAR2,
    asynchronous in BOOLEAN default FALSE,
    callbackTrigger in VARCHAR2 default NULL) return BOOLEAN is
    clientFileSize PLS_INTEGER := 0;
    clientFileChunks PLS_INTEGER := 0;
    clientFileInfo VARCHAR2(1000 char);
    result BOOLEAN := FALSE;
    dataBuffer VARCHAR2(32767);
    ignore VARCHAR2(2);
    lastErrorCode PLS_INTEGER;
    lastErrorArgs VARCHAR2(1000);
    encodedFile ORA_JAVA.JOBJECT;
    ftemp TEXT_IO.FILE_TYPE;
    tempFileName VARCHAR2(512);
    bool_ignore boolean;
         mesg('inside function--2');
    -- Client file cannot be null
    if clientFile is null then
    end if;
    -- AS file cannot be null. AppsServerFileWriter also handles this. Better to handle here.
    if NOT toDB AND spec1 is null then
    raise AS_FILE_NULL;
    end if;
    -- Make sure the client file to be uploaded exists and readable
    -- If we don't raise exception here, we end up creating an empty file on DB or AS
    if NOT webutil_file.file_is_readable(clientFile)
    OR webutil_file.file_is_directory (clientFile) then
    raise FILE_NOT_FOUND;
    end if;
    -- First check to see if a transfer is not currently happening
    if In_Progress then
    raise AGENT_BUSY;
    end if;
    -- reset the target
    m_toDB := toDB;
    -- Set up the file info
    clientFileInfo := clientFile||'|0|'||
    WebUtil_Core.setProperty(WebUtil_Core.WUT_PACKAGE,'WUT_FILE_INFO', clientFileInfo);
    mesg('clietfileinfo: '||clientFileInfo);
    -- get the size and chunk info of the client side file
    clientFileInfo := WebUtil_Core.getProperty(WebUtil_Core.WUT_PACKAGE,'WUT_FILE_INFO');
    clientFileSize := DelimStr.getNumber(clientFileInfo,1,true,'|');
    mesg('size: '||clientFileSize);
    if clientFileSize = 0 then
    -- no need to close AS file since it is not yet opened.
    end if;
    clientFileChunks := DelimStr.getNumber(clientFileInfo,2,true,'|');
    -- Set up the Open command
    if toDB then
    if not m_DBEnabled then
    end if;
    if not WebUtil_DB_Local.openblob(spec1, spec2, spec3,'W', m_maxTransferSize) then
    end if;
    if not WebUtil_Core.checkJava then
    raise NO_JAVA;
    end if;
    if not checkASACL(spec1,m_writeACL) then
    end if;
    if not JAVA_APPSERV_WRITER.openFile(jobj,spec1) then
    lastErrorCode := JAVA_APPSERV_WRITER.getLastError(jobj);
    lastErrorArgs := JAVA_APPSERV_WRITER.getLastErrorArgs(jobj) ;
    end if;
    end if;
    -- Is this Async? if So we do nothing more here just set the callback and kick it off
    if asynchronous then
    -- set callbackTrigger even if it is null. we will take care
    -- before calling
    ignore := WebUtil_Core.getProperty(WebUtil_Core.WUT_PACKAGE,'WUT_TRANSFER');
    m_chunks := clientFileChunks;
    m_fileSize := clientFileSize;
    m_uploadSucceeded := NULL;
    if not toDB then
    m_persistObj := ORA_JAVA.NEW_GLOBAL_REF(jobj);
    end if;
    result := true;
    if NOT toDB then
    encodedFile := JAVA_FILE.createTempFile('WUAS','.enc');
    tempFileName := JAVA_FILE.getPath(encodedFile);
    end if;
    -- loop through each chunk
    for i in 1..clientFileChunks LOOP
    dataBuffer := WebUtil_Core.getProperty(WebUtil_Core.WUT_PACKAGE,'WUT_TRANSFER',false);
    if (WebUtil_Core.isError) or (dataBuffer is null) then
    raise AGENT_BUSY;
    end if;
    -- Write to the correct place
    if toDB then
    ftemp := TEXT_IO.FOPEN(tempFileName, 'W');
    TEXT_IO.PUT(ftemp, dataBuffer);
    -- if not JAVA_APPSERV_WRITER.WriteData(jobj,dataBuffer) then
    if not JAVA_APPSERV_WRITER.decodeBASE64File(jobj,tempFileName) then
    lastErrorCode := JAVA_APPSERV_WRITER.getLastError(jobj);
    lastErrorArgs := JAVA_APPSERV_WRITER.getLastErrorArgs(jobj) ;
    end if;
    end if;
    end LOOP;
    if toDB then
    if WebUtil_DB_Local.CloseBlob(clientFileSize) then
    result := true;
    end if; -- close
    bool_ignore := JAVA_FILE.DELETE_(encodedFile);
    if JAVA_APPSERV_WRITER.CloseFile(jobj,clientFileSize) then
    result := true;
    lastErrorCode := JAVA_APPSERV_WRITER.getLastError(jobj);
    lastErrorArgs := JAVA_APPSERV_WRITER.getLastErrorArgs(jobj) ;
    end if;
    end if;
    end if; -- async
    return result;
    when CLIENT_FILE_EMPTY then
    WebUtil_Core.Error(Webutil_Core.WUT_PACKAGE,133,'WEBUTIL_FILE_TRANSFER.UploadInt', clientFile);
    return false;
    when CLIENT_FILE_NULL then
    return false;
    when AS_FILE_NULL then
    return false;
    when FILE_NOT_FOUND then
    WebUtil_Core.Error(Webutil_Core.WUT_PACKAGE,129,'WEBUTIL_FILE_TRANSFER.UploadInt', clientFile);
    return false;
    return false;
    when AGENT_BUSY then
    return false;
    when READWRITE_ERROR then
    return false;
    when NO_JAVA then
    return false;
    when WebUtil_Core.BEAN_NOT_REGISTERED then
    ||' bean not found. WEBUTIL_FILE_TRANSFER.UploadInt will not work');
    when WebUtil_Core.PROPERTY_ERROR then
    END UploadInt;

  • How to save PDF file in a particular shared location

    Hi All,
    I am trying to save generated PDF file in a particular location like C:/Documents and Settings/FolderName/My Documents/test.png.
    But Its givinhg following error.
    [ERROR] [Image_Saver_0]ImageSaver: Access to the file path /C:/Documents and Settings/FolderName/My Documents/test.png is not allowed .
    I am Using Image Saver action block.
    To this passing PDF_Document output as Input to "Encoded image" of Image saver action block.
    passing  path as above in "Path" of Image saver action block.
    MII version :14.0 SP4.
    Can anybody suggest me how to give path to store PDF files in a particular location.
    Rajee .

    Hello  Hari,
    Thanks for your reply.
    I am  trying to save currently on my local machine.
    I also tried as suggested by Raman ,but its not working.
    If I am trying to save in server machine, I am getting different error like
    [ERROR] [Image_Saver_0]ImageSaver: \\01hw601622\temporaryshare\Temp\test.png (Logon failure: unknown user name or bad password) Exception: [\\01hw601622\temporaryshare\Temp\test.png (Logon failure: unknown user name or bad password)] ".
    Folder name "Temp" is already created in this machine.
    Path I am giving like "\\01hw601622\temporaryshare\Temp\test.png" in my Image saver action block.
    My transaction is like this.
    Kindly suggest me if I am wrong.
    Rajee Vuta.

  • How to Save Pdf file in a particular format

    Hi Experts,
                        Can anybody tell me how to save a pdf file in a particular format,My requirement is i have a print button in webdynpro ,when ever user clicks on print ,adobe form is opened ,if user clicks on save .Form is saving with adobe form name .My requirement is it should be saved as ID NO.Date.Pdf  form lets Id is 0456 ,form should be saved as 0456.040614.pdf format, Thanks in Advance

    Hi Sandesh,
    Please provide the complete code from print & save button.
    Thanks & Regards,
    Balamurugan G

  • How to save pdf files to a folder on my tablet?

    How do I save an edited pdf document to a folder on my 'desktop', where I can find it again?  I am using an android tablet.

    I am not sure what you mean by saving on the 'desktop'. Are you trying to share the file across devices?
    However, in case you want to save a file in a different folder in Adobe Reader for Android, you can go tap on the 'Documents' tab. On the top toolbar, you will see an 'Edit' option. Tap on it and select the file(s) you want to move. Now, on the top toolbar, you would see an icon which looks like a folder with an arrow. Tap on this and now you can enter the desired location where you want to save this file

  • How to save pdf files from mail to i pad2

    How can i save a pdf file from e mail to the i pad2 ???

    From Google what?  There are so many Googe services (mail, docs, drive, ...) that you really need to provide more details.  Also what exact problems you experience.

  • How to save PDF file with predefined name?

    I am new in LiveCycle Designer. I have a requirement to save a PDF file with predefined file name. When user clicks a "Save as PDF" button, the fillable form is saved with the name from the form fields (e.g. FormID_UserID_Timesstamp...)
    I added a button (btnSavePDF) to the form (Control Type=Regular). Then I added an action with the Condition:"When button is clicked" and the Result: "Save the form". I got the JavaScripts it genreated:
      CoverPageForm.FormPage.btnSavePDF::click - (JavaScript, client)
    When I tested it in Adobe Acorbat XI, I have option to save it as .pdf or other file formats. My questions is how can I save it with the predefined file name as a .pdf file, instead user has option to change the file name or change the file format? Can app.execMemuItem() method take other parameters?

    You can't do it with app.execMenuItem. You can use the doc.saveAs method, but it has to be executed in a privileged context. For your application this means a folder-level JavaScript file that would have to be installed on each user's machine or with code in a certified PDF that the users chooses to trust to allow for privileged JavaScript execution.
    More information on the saveAs JavaScript method:
    and some sample code relevant to the folder-level JavaScript option:
    All of the sample code shown is for a regular PDF, so you'll have to adjust slightly for using with an XFA.

  • How to save pdf files to skydrive/PC on Windows Phone 7.8?

    I cannot save my pdf files to skydrive or PC on my Nokia Lumia 800 which runs on Windows Phone 7.8. I mean there is no option provided by Adobe on WP 7.8, to save/have a backup of pdf files. When is Adobe going to provide this most important feature to WP 7.8 users?

    Thanks for the suggestion my dear friend. But, Apitron PDF Viewer is compatible with Windows Phone 8 phones. Mine is Windows Phone 7.8 (Nokia Lumia 800 phone)

  • How to upload pdf file to DataBase using webdynpro abap.

    Hi Experts,
    how can i upload a pdf file in document server using webdynpro abap and display the same  pdf file on the view using webdynpro abap.
    Please Provide requried information .
    Thanks & Regards.

    NB - the "data" that is returned by these classes is the data as defined in an adobe form - it doesn't return the content of non-form PDF documents.
    The PDF must be an interactive form ( although that doesn't restrict you to using the SAP process for creating the form is my understanding - but I could be wrong. )
    Edit - I was wrong! ONLY PDF documents that have been created by the ADS can have data extracted using these classes. So unless you are using Adobe interactive forms - then you will get no value from this functionality - and if you're using AIF then you're probably just use the standard UI element
    Edited by: Chris Paine on Oct 26, 2010 6:04 PM

  • How to save pdf files from google?

    Please help me to download pdf files from google

    From Google what?  There are so many Googe services (mail, docs, drive, ...) that you really need to provide more details.  Also what exact problems you experience.

Maybe you are looking for

  • Missing business systems in model configurator

    Hello, i am on PI 7.1 and have to configure a SRM scenario. In step "assign communication component" (business system) in the model configurator all business systems are missing. Please the screenshot: [] What

  • My Macbook Pro is too slow!

    I am only running Firefox, Papers2 and Pages and 3.99GB of my 4GB ram is being used up. A detailed description of my system I took with EtreCheck is below. There is a kernel task that is using a lot of my memory, does anyone know what this is ? I hop

  • No HDMI sound to my TV with my g6 notebook with HDMI Codec drivers installed.

    No HDMI sound to my TV with my g6 notebook with HDMI Codec drivers installed using Windows 7.

  • Header vs Detail accumlation

    I've created a custom folder which combines the header table with the detail table. From the Custom Folder, I've created a worksheet which shows this information. Now, how can I rollup the detail information without it adding the header numerics. Exa

  • Netcfg problem with wep shared key

    hello guys, I would like to connect to a wireless device with netcfg. The device has a WEP encryption with shared key authentication. I'm able to connect using the gnome nm-applet, but with netcfg i keep getting the "Wireless association failed" erro