Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

import/export BLOB from/to a GIF pricture file

wyfwongMar 20 2003
I can import a file into a CLOB datatype. First a directory object is created to point to the relevant filesystem directory:

CREATE OR REPLACE DIRECTORY documents AS 'C:\';
Next we create a table to hold the CLOB:

CREATE TABLE tab1 (col1 CLOB);
Finally we import the file into a CLOB datatype and insert it into the table:


DECLARE
v_bfile BFILE;
v_clob CLOB;
BEGIN
INSERT INTO tab1 (col1)
VALUES (empty_clob())
RETURN col1 INTO v_clob;

v_bfile := BFILENAME('DOCUMENTS', 'Sample.txt');
Dbms_Lob.Fileopen(v_bfile, Dbms_Lob.File_Readonly);
Dbms_Lob.Loadfromfile(v_clob, v_bfile, Dbms_Lob.Getlength(v_bfile));
Dbms_Lob.Fileclose(v_bfile);

COMMIT;
END;
/

I would like to do the same for BLOB by importing a GIF/JPG file to the column with datatype BLOB, but it does not work. Can anyone help?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 17 2003
Added on Mar 20 2003
0 comments
309 views