DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Retrieving Word Document..

Threaded View

  1. #2
    Join Date
    Jan 2002
    Location
    Netherlands
    Posts
    1,587
    I knew this would be the next question.
    What exactly do you mean by retrieving, retrive through the sqlplus screen?

    There are 6(could be more) programmtic env to do the insert and read...
    pl/sql (dbms_lob)
    c(oci)
    c/c++(pro*C)
    cobol(pro*cobol)
    vb(oo4o)
    java(jdbc)

    Since you're using pl/sql...

    If your retrieve is "reading the data"...
    Code:
    CREATE OR REPLACE PROCEDURE read_prc IS
       Lob_loc       BFILE := BFILENAME('your_dir', 'your_doc');
       Amount        INTEGER := 32767;
       Position      INTEGER := 1;
       Buffer        RAW(32767);
    BEGIN
       /* Select the LOB: */  
       SELECT mydoc INTO Lob_loc FROM worddoc_table 
          WHERE doc_id = 1;
       /* Open the BFILE: */  
       DBMS_LOB.OPEN(Lob_loc, DBMS_LOB.LOB_READONLY);
       /* Read data: */  
       DBMS_LOB.READ(Lob_loc, Amount, Position, Buffer);
       /* Close the BFILE: */  
       DBMS_LOB.CLOSE(Lob_loc);
    END;

    If retrieving means displaying...

    Code:
    CREATE OR REPLACE PROCEDURE displayBFILE_proc IS 
       Lob_loc  BFILE; 
       Buffer   RAW(1024); 
       Amount   BINARY_INTEGER := 1024; 
       Position INTEGER        := 1; 
    BEGIN 
       /* Select the LOB: */ 
       SELECT mydoc INTO Lob_loc 
       FROM worddoc_table WHERE doc_id = 1; 
       /* Opening the BFILE: */ 
       DBMS_LOB.OPEN (Lob_loc, DBMS_LOB.LOB_READONLY); 
       LOOP 
          DBMS_LOB.READ (Lob_loc, Amount, Position, Buffer); 
          /* Display the buffer contents: */ 
          DBMS_OUTPUT.PUT_LINE(utl_raw.cast_to_varchar2(Buffer)); 
          Position := Position + Amount; 
       END LOOP; 
       /* Closing the BFILE: */ 
       DBMS_LOB.CLOSE (Lob_loc); 
       EXCEPTION 
       WHEN NO_DATA_FOUND THEN 
          DBMS_OUTPUT.PUT_LINE('End of data'); 
    END;

    I haven't tried it(so don't just do copy and paste)you might want to adjust it...

    but using jdbc stream you can also store the contents into another os file, I'll have to try it on my box first...
    Last edited by Tarry; 05-20-2003 at 08:40 AM.
    Tarry Singh
    I'm a JOLE(JavaOracleLinuxEnthusiast)
    TarryBlogging
    --- Everything was meant to be---

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width