Import BLOB Contents
The following article presents a simple methods for importing a file into a BLOB datatype. First a directory object is created to point to the relevant filesystem directory:Next we create a table to hold the BLOB:CREATE OR REPLACE DIRECTORY images AS 'C:\';
Finally we import the file into a BLOB datatype and insert it into the table:CREATE TABLE tab1 (col1 BLOB);
DECLARE
l_bfile BFILE;
l_blob BLOB;
BEGIN
INSERT INTO tab1 (col1)
VALUES (empty_blob())
RETURN col1 INTO l_blob;
l_bfile := BFILENAME('IMAGES', 'MyImage.gif');
DBMS_LOB.fileopen(l_bfile, Dbms_Lob.File_Readonly);
DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
DBMS_LOB.fileclose(l_bfile);
COMMIT;
END;
/
Hope this helps. Regards Tim...Back to the Top.
