Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> LOBs Questions. Need help.

LOBs Questions. Need help.

From: Meomeo Nguyen <meomeo22_at_yahoo.com>
Date: Tue, 10 Sep 2002 09:55:17 -0700 (PDT)
Message-Id: <22528.293347@fatcity.com>


--0-1658667313-1031676917=:89218
Content-Type: text/plain; charset=us-ascii

Hi All,
I want to load PDF files into the database and view the content of the lobs column. Below is what I did step by step. Anyone please point out what did I do wrong in my procedure. I am still unable to view the content of the Lobs column. I need you all for your help. Please note that I already stored the PDF file (‘6117cdsapx.pdf’) on my Oracle server site at /Disk05/test CREATE TABLE MY_BOOK_TEXT ( FILE_DESC VARCHAR2 (200), BOOK_FILE BFILE);   CREATE DIRECTORY TEST AS ‘/Disk05/test’;  

DECLARE pdf BFILE;

BEGIN             pdf := BFILENAME (‘TEST’, ‘6117cdsapx.pdf’);

END; /

INSERT INTO MY_BOOK_TEXT (FILE_DESC, BOOK_FILE ) VALUES (‘IBM Microprocessor’, BFILENAME(‘TEST’, ‘6117cdsapx.pdf’);

 This procedure has been executed on the server site. When executing the procedure, it got a warning message: Procedure created with compilation errors.

CREATE OR REPLACE PROCEDURE displayLOB_proc IS Lob_loc BLOB;
Buffer RAW(1024);
Amount BINARY_INTEGER := 1024;
Position INTEGER := 1;
BEGIN
   /* Select the LOB: */
   SELECT m.Map_obj.Drawing INTO Lob_loc    FROM Multimedia_tab m WHERE m.Clip_ID = 1;    /* Opening the LOB is optional: */
   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 LOB is mandatory if you have opened it: */    DBMS_LOB.CLOSE (Lob_loc);
   EXCEPTION
      WHEN NO_DATA_FOUND THEN 
         DBMS_OUTPUT.PUT_LINE('End of data'); 
End;
/

Thank you all for your help in advance

Lenka



Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost --0-1658667313-1031676917=:89218
Content-Type: text/html; charset=us-ascii

<P>Hi All,
<P>I want to load PDF files into the database and view the content of the lobs column.&nbsp; Below is what I did step by step.&nbsp; Anyone please point out what did I do wrong in my procedure.&nbsp; I am still unable to view the content of the Lobs column.&nbsp; I need you all for your help.&nbsp;
<P>Please note that I already stored the PDF file (‘6117cdsapx.pdf’) on my Oracle server site at /Disk05/test
<P class=MsoNormal>CREATE TABLE MY_BOOK_TEXT<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>(</P>
<P class=MsoNormal>FILE_DESC VARCHAR2 (200),</P>
<P class=MsoNormal>BOOK_FILE BFILE);</P>
<P class=MsoNormal><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>&nbsp;</o:p></P>
<P class=MsoNormal>CREATE DIRECTORY TEST AS ‘/Disk05/test’;</P>
<P class=MsoNormal><o:p>&nbsp;</o:p></P>
<P class=MsoNormal>DECLARE </P>
<P class=MsoNormal style="TEXT-INDENT: 0.5in">pdf<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>BFILE;</P>
<P class=MsoNormal>BEGIN</P>
<P class=MsoNormal><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>pdf<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>:= BFILENAME<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>(‘TEST’, ‘6117cdsapx.pdf’);</P>
<P class=MsoNormal>END;<o:p>&nbsp;</o:p></P>
<P class=MsoNormal><o:p>/</o:p></P>
<P class=MsoNormal>INSERT INTO MY_BOOK_TEXT (FILE_DESC, BOOK_FILE )</P>
<P class=MsoNormal>VALUES (‘IBM Microprocessor’, BFILENAME(‘TEST’, ‘6117cdsapx.pdf’);</P>
<P class=MsoNormal><FONT color=#bf005f><o:p>&nbsp;This procedure has been executed on the server site.&nbsp; When executing the procedure, it got a warning message: Procedure created with compilation errors.</o:p></FONT></P>
<P class=MsoNormal><SPAN style="FONT-FAMILY: monospace; FONT-SIZE: 10pt; mso-bidi-font-family: Tahoma">CREATE OR REPLACE PROCEDURE displayLOB_proc IS <BR>Lob_loc&nbsp;&nbsp;BLOB; <BR>Buffer&nbsp;&nbsp;&nbsp;RAW(1024); <BR>Amount&nbsp;&nbsp;&nbsp;BINARY_INTEGER := 1024; <BR>Position INTEGER := 1; <BR>BEGIN <BR>&nbsp;&nbsp;&nbsp;/* Select the LOB: */ <BR>&nbsp;&nbsp;&nbsp;SELECT m.Map_obj.Drawing INTO Lob_loc <BR>&nbsp;&nbsp;&nbsp;FROM Multimedia_tab m WHERE m.Clip_ID = 1; <BR>&nbsp;&nbsp;&nbsp;/* Opening the LOB is optional: */ <BR>&nbsp;&nbsp;&nbsp;DBMS_LOB.OPEN (Lob_loc, DBMS_LOB.LOB_READONLY); <BR>&nbsp;&nbsp;&nbsp;LOOP <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBMS_LOB.READ (Lob_loc, Amount, Position, Buffer); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Display the buffer contents: */ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBMS_OUTPUT.PUT_LINE(utl_raw.cast_to_varchar2(Buffer)); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Position := Position + Amount; <BR>&nbsp;&nbsp;&nbsp;END LO!
OP; <BR>&nbsp;&nbsp;&nbsp;/* Closing the LOB is mandatory if you have opened it: */ <BR>&nbsp;&nbsp;&nbsp;DBMS_LOB.CLOSE (Lob_loc); <BR>&nbsp;&nbsp;&nbsp;EXCEPTION <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHEN NO_DATA_FOUND THEN <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBMS_OUTPUT.PUT_LINE('End of data'); <BR style="mso-special-character: line-break">End;<BR style="mso-special-character: line-break">/</SPAN></P>
<P class=MsoNormal><FONT face="">Thank you all for your help in advance</FONT></P>
<P class=MsoNormal>Lenka</P><p><br><hr size=1>Yahoo! - We Remember<br>
<b>9-11: A tribute to the more than 3,000 lives lost</b>
Received on Tue Sep 10 2002 - 11:55:17 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US