import/export BLOB from/to a GIF pricture file
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?