Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Daya.

Asked: February 04, 2003 - 10:54 pm UTC

Last updated: March 10, 2004 - 4:16 am UTC

Version: 8.1.7

Viewed 1000+ times

You Asked

Hi Tom!
I have a procedure ins_lob by which i insert file with contents into database.
For reading the data from database i have a procedure called read_lob which is like:
SQL> set serveroutput on size 100000
SQL> exec read_lob(7);
PL/SQL procedure successfully executed.
procedure read_lob(p_id in demo.id%type) is
Lob_loc BLOB;
m integer;
n integer;
BEGIN
SELECT theBlob INTO Lob_loc
FROM demo
WHERE id = p_id;
m := dbms_lob.getlength(lob_loc);
dbms_output.put_line('THE LENGTH IS: '||dbms_lob.getlength(lob_loc));
-- just print out the first 200 bytes since put_line
-- cannot do more then 255
for i in 1..m loop
if i =1 then
dbms_output.put_line(utl_raw.cast_to_varchar2( dbms_lob.substr( lob_loc, 230, 1 ) ) );
n := 230+230;
else
if n<m then
dbms_output.put_line(utl_raw.cast_to_varchar2( dbms_lob.substr( lob_loc,230,n ) ) );
n := n+230;
end if;
end if;
end loop;
END;

Using the above procedure, i am able to display the details too. But i need to retrieve the blob data which is having delimiters (like ','or '|') into separate fields of another table. That is first i will retrieve the data and give it as an input to another table. Can i try the same with BLOB datatype or shall i use CLOB datatype?
Hope to get your valuable feedback.
Thanks in advance
Daya



and Tom said...

see
</code> http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:1352202934074 <code>

you can use a blob -- that shows how i "parse" a file using dbms_lob on a bfile -- you can do the same with a blob if you like.

clob would be easier of course. and if the data is actually TEXT, a better solution as it would support the various character set conversions we do -- whereas a blob would not.

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, December 17, 2003 - 3:57 pm UTC


Great

anupama, March 10, 2004 - 4:16 am UTC

It was very helpful

More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here