Ask the Expert

Saving files larger than 4K in Oracle 8

How can we save doc or text files that are larger than 4K in Oracle 8 or 8i through LOB? Please tell me in detail with example.

    Requires Free Membership to View

Here is the code to load a file. It's straight to load the file:
-- the table you want to load to

drop table blobs;
create table blobs
( id        varchar2(255),
  theBlob   blob
)
/
-- declare a directory object
create or replace directory MY_FILES as '/export/home/tkyte/public_html';

-- script to load a file, aria.gif is the file to load:
declare
    l_bfile bfile;
    l_blob  blob;
begin
    insert into blobs values ( 'MyGif', empty_blob() )
    return theBlob into l_blob;

    l_bfile := bfilename( 'MY_FILES', 'aria.gif' );
    dbms_lob.loadfromfile( l_blob, l_bfile, dbms_lob.getlength(l_bfile) );
    commit;
end;
/
dbms_lob.loadfromfile does all the loading of file; the file must exist in the directory given by the MY_FILES directory.


This was first published in June 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: