How to upload a file to a BLOB column in the DB using PL/SQL???

Hi
I am trying to upload a file to a BLOB column in my database. I wana do this using some pl/sql procedure.I don't wana use webutil. is it possible??? and if so can anybody help me with this???
Regards
Shiraz

Hello,
This is a stored procedure sample that show how insert into CLOB, BLOB and BFILE columns
CREATE OR REPLACE PROCEDURE Insert_document
     PC$Type IN DOCUMENT.TYP%TYPE
    ,PC$Nom IN DOCUMENT.NOM_DOC%TYPE
    ,PC$Texte IN VARCHAR2
    ,PC$Image IN VARCHAR2 
    ,PC$Fichier IN VARCHAR2
   ) IS
  L$Blob BLOB;
  L$Clob CLOB;
  L$Bfile BFILE;
  LN$Len NUMBER := dbms_lob.lobmaxsize;
  LN$Num NUMBER ;
  LN$src_off PLS_INTEGER := 1 ;
  LN$dst_off PLS_INTEGER := 1 ;
  LN$Langctx NUMBER := dbms_lob.default_lang_ctx ;
  LN$Warn NUMBER;
  BEGIN
    -- Création of new raw --
    If PC$Fichier is not null Then
       L$Bfile := BFILENAME( 'FICHIERS_IN', PC$Fichier );
    End if ;
    -- Creation of temporary objetcs --
    dbms_lob.createtemporary( L$Clob, TRUE ) ;
    dbms_lob.createtemporary( L$Blob, TRUE ) ; 
    -- Loading text in CLOB column --
    If PC$Texte is not null Then
       L$Bfile := BFILENAME( 'FICHIERS_IN', PC$Texte );
       dbms_lob.fileopen(L$Bfile, dbms_lob.file_readonly);
       If dbms_lob.fileexists( L$Bfile ) = 1 Then
         dbms_output.put_line(PC$Texte || ' open' ) ;
         dbms_lob.loadclobfromfile(
                                   L$Clob,                -- Destination CLOB
                                   L$Bfile,               -- Source file pointer
                                   LN$Len,                -- # bytes to read
                                   LN$src_off,            -- Source start position
                                   LN$dst_off,            -- Target start position
                                   dbms_lob.default_csid, -- CSID
                                   LN$Langctx,            -- Language Context
                                   LN$Warn);              -- Warning message
         dbms_lob.fileclose(L$Bfile);
      Else
         raise_application_error( -20100, 'Erreur ouverture ' || PC$Texte ) ;
      End if ;
    End if ;
    -- Loading image in BLOB column --
    If PC$Image is not null Then
       L$Bfile := BFILENAME( 'FICHIERS_IN', PC$Image );
       dbms_lob.fileopen(L$Bfile, dbms_lob.file_readonly);
       dbms_lob.loadblobfromfile(
                                 L$Blob,       -- BLOB de destination
                                 L$Bfile,      -- Pointeur de fichier en entrée
                                 LN$Len,       -- Nombre d'octets à lire
                                 LN$src_off,   -- Position source de départ
                                 LN$dst_off);  -- Position destination de départ
       dbms_lob.fileclose(L$Bfile);
    End if ; 
    -- Save --
    Insert into DOCUMENT (ID, NOM_DOC, TYP, UTILISE, LOB_TEXTE, LOB_DATA, LOB_FICHIER)
           Values( SEQ_DOCUMENT.NEXTVAL, PC$Nom, PC$Type, NULL, L$Clob, L$Blob, L$Bfile ) ; 
    -- Free the temporary objects --
    dbms_lob.freetemporary( L$Clob ) ;
    dbms_lob.freetemporary( L$Blob ) ; 
  END;
/The table structure for this sample is the following:
CREATE TABLE DOCUMENT (
  ID           NUMBER (5) PRIMARY KEY,
  TYP          VARCHAR2 (20),
  UTILISE      VARCHAR2 (30),
  LOB_TEXTE    CLOB,
  LOB_DATA     BLOB,
  LOB_FICHIER  BFILE,
  NOM_DOC      VARCHAR2 (100))
/Francois

Similar Messages

  • How to upload/download file into/from blob column in ADF/JDev 11g.

    Hello to all.
    I found demo from Kuba user on that page: http://kuba.zilp.pl/?id=1
    But that demo is for release 10g and too complicated for me for this time (I'm fish in Jdeveloper).
    I can create some simple table view (of form view) with oracle connection with table with blob data.
    Blob column will content doc/xls/pdf ...etc.
    Now I can add two buttons for download and upload.
    What I have to do in next time?
    Is it possible to use some component or something?
    Thank you
    Ben

    I was able to accomplish downloading from a blob, but I'm trying to dynamically set the ContentType.
    As the table may contain different types of files, I'm setting the ContentType to #{row.Fileext}, where Fileext is set in SQL select as follows:
    pseudocode: get file extension, and set the content type based on file extension.
    sql select :decode(substr(fdv.file_name,instr(fdv.file_name,'.',-1,1)+1),'log','text/plain; charset=utf-8','xml','text/xml','xls','application/vnd.ms-excel','tif','image/tiff','jpg','image/jpeg','unknown')
    I rather use a fuction/method, and tried the following instead:
    ContentType = #{backingBeanScope.backing_processReqs.FileAttachContType}
    where FileAttachContType =
    public class ProcessReqs {
    public String FileAttachContType() {
    // code to substring filename for extension and decode values
    return strContType
    But I get the following error:
    Error 500--Internal Server Error
              javax.el.PropertyNotFoundException: The class 'sunrider.reqpoportal.view.backing.ProcessReqs' does not have the property 'FileAttachContType'.
                   at javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:547)
                   at javax.el.BeanELResolver.getValue(BeanELResolver.java:249)
                   at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
    Ideas?
    PS: Kuba, I've been trying to get to your blog all day, and it would just time out.
    Thanks everyone in advance!
    -R
    Edited by: user6631964 on Jul 24, 2009 5:55 PM

  • How to load externl files (PDF) into BLOB column.  Please help.

    Hi All,
    I've currently been working on loading many external binary files (PDF) into BLOB column. After some digging, I learn that the SQL*LOADER can be used to load data from external files into table. I also got help from another forummate mentioning to use PL/SQL procedure to do so. Since I have not done anything like this before. So, my question is what is the simple approach needed to upload PDF files into a table(there is only one table containing BLOB column in my database). In addition, the LOBs can not be query-able, I wanted to list the contents of the LOBs column to make sure that I did successfully upload data into the database. How can I do that?. I do need your help. Please direct me step by step how to do so. Your help is greatly appreciated.
    Regards,
    Trang

    Hi,
    If the following link helps to you then great.
    http://www.exefind.com/oralobeditor-P25468.html
    Regards,
    Sailaja

  • How to display binary file saved in BLOB column in Discoverer PLUS /VIEWER

    HI, Friends,
    I tried to display the binary file saved in the database in BLOB column with the *.doc or *.xls fomats, but it seemed not work at all. I can display them in discoverer DESKTOP, but not the web version PLUS or VIEWER. MY Discoverer PLUS/VIEWER version is 9.0.4.45.02 and the database is 9.2.0.4. Are there any special setting/configuration in somewhere (Discoverer administration/Applicaiton server/PLUS/VIEWER?)
    Any help /information will be greatly appreciated.
    Thanks a lot.

    Hi,
    Sorry but this feature is not available in the web version of 9.0.4.45. You will have to write your own mod_plsql function to download the file.
    Rod West

  • How to open a file form a blob column?

    I'm storing some files in oracle 9.2 in a blob column, although i can't open them using php 4, I'm using this script :
    <?php
         $SQL="SELECT ID_ARCHIVO,CONTENT";
              $SQL=$SQL." FROM ARCHIVOS_PRUEBAS ";
              $SQL=$SQL." WHERE ID_ARCHIVO =".$v_ID_ARCHIVO ;
              $c=OCILogon("$v_USER" , "$v_PASS" ,"$v_CONEXION" );
              $s = OCIParse($c,$SQL );
              if (!OCIExecute($s)) { print "execution failed"; exit(); }
         OCIFetchInto($s,&$arr,OCI_RETURN_LOBS);
         echo $arr["CONTENT"]->load();
              ?>
    it shows this error
    Fatal error: Call to a member function on a non-object in ov_archivo_detail_test.php on [echo $arr["CONTENT"]->load(); ].
    I know the data is stored correctly since i used toad to save and open the blob file and it was ok, but i still can't find a right way to show the file from the web.
    Message was edited by:
    user560595

    Hi,
    <br>
    <br>
    Did you already try take a look on
    Oracle+PHP Cookbook: Working with LOBs in Oracle and PHP ?
    <br>
    <br>
    Cheers

  • How to upload a file to a blob By ADF uix

    I need to add a file to a record as an accessory;
    I now use ADF-Uix?How do it?
    Someone can help me !
    Thanks

    The forum search would be my first try...
    Then google...
    This has been asked at least once a week and got correct answers...
    Timo

  • How to batch upload PDF files into database BLOB

    Hello.
    I have a requirement to batch upload PDF files into BLOB column of an Oracle 8.1.7 table from Forms 6i Web. The content of the blob column (ie. the PDF content) MUST be displayable from all client software (eg. Oracle Web forms, HTML forms, etc.)
    Our environment is
    Middle-tier is 9iAS on Windows/2000
    Database is Oracle 8.1.7.0.0 on VMS
    Oracle Web Forms 6i Patch 10
    Basically my Oracle web form program will display a list of PDF files to upload and then the user can click on the &lt;Upload&gt; button to do the batch upload. I have experimented the following approaches but with no luck.
    1. READ_IMAGE_FILE forms built-in = does NOT work because it cannot read PDF file. I got error FRM-47100: Cannot read image file
    2. OCX and OLE form item = cannot use this because it does NOT work on the Web. I got error FRM-41344 OLE object not defined
    3. I cannot use DBMS_LOB to do the load because the PDF files are not in the database machine.
    4. Metalink Note 1682771.1 (How to upload binary documents back to database blob column from forms). When I used this, I got ORA-6502 during the hextoraw conversion. In using this solution, I have downloaded a bin2hex.exe from the Google site. I've noticed that when I looked at the converted HEX file, each line has the character : (colon) at the beginning of each line. I know the PDF file has been converted correctly to HEX format because when I convert the HEX file back to BIN format using hex2bin.exe, I'm able to display the converted bin file in Acrobat Reader. When I removed the : (colon) in the HEX file, I did NOT get the ORA-6502 error but I CANNOT display the file in Acrobat Reader. It gives an error "corrupted file".
    5. upload facility in PL/SQL Web toolkit - I tried to automatically submit the html form (with htp.p) but it does NOT load the contents of the file. I called the URL from Oracle forms using web.show_document. There seems to be issues with Oracle Web forms (JInitiator) and HTML (+ htp.p).
    The other options I can think of at this point are:
    1. Use SQL*Loader to do the batch upload via SQL*Net connection and use HOST() built-in from Oracle Webforms to execute SQL*Loader from the 9iAS.
    2. Write a Visual Basic program that reads a binary file and output the contents of the file into a byte array. Then build a DLL that can be called from Oracle webforms 6i via ORA_FFI. I don't prefer this because it means the solution will only work for Windows.
    3. Write a JSP program that streams the PDF file and insert the contents of the PDF file into blob column via JDBC. Call JSP from forms using web.show_document. With this I have to do another connection to the database when I load the file.
    4. Maybe I can use dbms_lob by using network file system (NFS) between the application server and VMS. But this will be network resource hungry as far as I know because the network connection has to be kept open.
    Please advise. Thank you.
    Regards,
    Armando

    I have downloaded a bin2hex.exe from the Google site.
    ... each line has the character : (colon) at the
    beginning of each line. I'm afraid it isn't a correct utility. I hope you'll find the source code of a correct one at metalink forum:
    Doc ID: 368771.996
    Type: Forum
    Subject: Uploading Binary Files: bin2hex and hex2bin do not reproduce the same file
    There is some links to metalink notes and some example about working with BLOB at http://www.tigralen.spb.ru/oracle/blob/index.htm. Maybe it helps. Sorry for my English. If there is any problem with code provided there, let me know by e-mail.

  • How to Upload a PDF file into BLOB column in a table using Forms 9i

    Can anyone tell me how to upload a PDF file from client system using File dialog window and store its content in BLOB column in a table. The file to be uploaded will be in client side.

    Hi,
    please, search a bit on the forum before do a question:
    Just searching by "upload blob pdf" ...
    How to batch upload PDF files into database BLOB
    Regards,
    Jose.

  • How to upload a file into a db blob column from adf page

    How to upload a file into a db blob column from adf page
    Which option to use ?

    The forum search would be my first try...
    Then google...
    This has been asked at least once a week and got correct answers...
    Timo

  • How to upload a file with a HTML form into a BLOB ?

    Hi,
    I want to upload a file into a BLOB.
    I have created a procedure in PL/SQL whitch generates an html form.
    You can upload a file with <input type="file" name="my_file">.
    How can I insert this file into my database ?
    Thank's for your Help
    Estelle

    Hi Estelle,
    Portal Applications forum is a more apporpriate forum for such questions. Please post your question there.
    Thanks,
    Ravi

  • How to upload binary file in database?

    Using servlets..how to upload binary file into database...
    How to get the data of file in servlet...
    Please reply...i'm unable to find exact code...that i want..

    You need to do two separate parts: accept the file from a HTTP multi-part POST and then stream it into a BLOB on the database. To do the former, download Jakarta Commons FileUpload. There is extensive documentation on how to write a simple handler for the upload. You then need to send the data to a BLOB. The specifics vary from database to database but generally you will insert or update a row with an empty blob, get a reference to the blob, pipe the data and then commit.
    If you do a quick forum search, this question has been asked (and answered) dozens of times. Some of the replies may even have code for you. Best of luck.
    - Saish

  • How to upload a file to database in Apex 4.2.2?

    How to upload a file to database in Apex 4.2.2 in Existing Application? Also How to view the uploaded file within this application?
    Any help to his question is very appreciated?
    Thanks,
    Prak.

    980835 wrote:
    Please update your forum profile with a real handle instead of "980835".
    Actually we want to upload the file to our own table and retrive from it as well. Is it possible to see the file of person whom we are pulling?
    This is covered in the documentation: About BLOB Support in Forms and Reports. There's also a tutorial in the Oracle Learning Library.

  • How to upload Excel file in BI using function module in abap program

    How to upload Excel file in BI using function module in abap program?

    Hi Anuj,
    To upload the file , you can try a standard program "RSEPSFTP" .
    while you execute the program , a selection screen appears in which the inputs should be give as
    RFC destination - The target server name
    FTP command- PUT
    local file - your file name
    local directory - path of your local file
    remote file - your target file name
    remote directory - where it has to be stored
    Hope this is useful for you
    Thanks & regards
    Anju

  • How to upload pdf file in a canvas in flex web application?

    how to upload pdf file in a canvas in flex web application?

    Hey saif.antri,
    You can view PDFs and more using iBooks on your iPhone:
    iBooks: Viewing, syncing, saving, and printing PDFs on iPhone, iPad, and iPod touch
    http://support.apple.com/kb/HT4227
    Have a great day,
    Delgadoh

  • How to upload excel file in Webdynpro application using ABAP

    Hi Experts,
    Am developing a webdynpro application in which it will take an excel file as input and display the contents in the form of a table in output. I am able to upload tab delimited text file and populate the table using the below code but not able to do the same with .xls file. Pls let me know if I need to use a different function module for upload excel file.
    get single attribute
      wd_context->get_attribute(
        EXPORTING
          name =  `DATASOURCE`
        IMPORTING
          value = l_xstring ).
      CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
        EXPORTING
          in_xstring = l_xstring
        IMPORTING
          out_string = l_string.
      SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
    Bind With table Element.
      LOOP AT i_data INTO l_string.
        SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
        READ TABLE fields INTO lv_field INDEX 1.
        fs_table-name = lv_field.
        READ TABLE fields INTO lv_field INDEX 2.
        fs_table-age = lv_field.
        APPEND fs_table TO t_table1.
      ENDLOOP.
    lo_nd_data = wd_context->get_child_node( 'DATA_TAB' ).
    lo_nd_data->bind_table( T_TABLE1 ).
    Thanks,
    Subathra

    Dear Exports
    Can anyone guide me how to uplode the .xlsx or ..xls formatted excel file using abap webdynpro without converting it to .txt file. Because my client requirement is only to upload the excel file. because to convert the .xlsx flie to .txt file it will be time taking and cost expanssive. Another requirement is suppose today i have create a application for uploading a file which has 8 columns and 10 rows. suppose tomorrow the client will make some changes in that flat file means the client will add 2 extra columns and 10 more columns in that fil. and will upload that file. Then the new file will be display on the browser or old file. but my requirement is to display the new file in browser.
    Can anyone kindly help to solve my problem. I am completely fresher in this field and I need to do it as soon as possible. Please help to solve the problem. 
    Regards
    Rashmita

Maybe you are looking for

  • After updating to OSX 10.7.3, my search (spotlight) no longer works. Is there a fix for this?

    After updating to OSX 10.7.3, my search (spotlight) no longer works. Is there a fix for this?

  • Unable to boot Windows 7 Home Premium 64bit dv6

    Hello, I have a HP dv6 that I force shutdown. Upon reboot, it asks me to do a Windows diagnostic and if I select that option, all I see is a blue screen (not the blue screen of death) and nothing else happens. No progress bar, nothing...a DOS window

  • Webpage link problem in adobe acrobat 8 pro

    Webpage links work fine locally. When I put these PDFs with webpage links online, they still work fine. After i combine PDFs as a package, webpage links only work fine locally. The links cannot open after i put the PDF package on our website. Pls giv

  • Flex SDK 3.5 support

    Hello, I would like to know if there is any due date to which the Adobe Flex SDK 3.5 will continue to be supported by the adobe flash player. I dont know if this is the right way of asking this question, but we have a very large Adobe Flex app. In th

  • Saving a file marks it for re-compilation

    Hello, the following scenario: In CVI2013, open a project, edit the source code, build and run the project, and then quit the executable such that you're back in the IDE. Click the green triangle again and the executable will be run 'immediately'. No