Hello expert;
I have the following sample code below
DECLARE
l_bfile BFILE;
l_blob BLOB;
l_dest_offset INTEGER := 1;
l_src_offset INTEGER := 1;
BEGIN
INSERT INTO tab1 (id, blob_data)
VALUES (1, empty_blob())
RETURN blob_data INTO l_blob;
l_bfile := BFILENAME('BLOB_DIR', 'MyImage.gif');
DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
-- loadfromfile deprecated.
-- DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
DBMS_LOB.loadblobfromfile (
dest_lob => l_blob,
src_bfile => l_bfile,
amount => DBMS_LOB.lobmaxsize,
dest_offset => l_dest_offset,
src_offset => l_src_offset);
DBMS_LOB.fileclose(l_bfile);
COMMIT;
END;
/
it was gotten from the following link below. My question is based on the insert statement in the code. The code is meant to import file into a blob datatype and insert it into the table.
Question
Why is the insert statement at the beginning of the process? Shouldn't the insert statement be at the end, Hence my thought process is
1. saving the file into a blob variable and then using that variable in the insert statement at the end to enter the blob into a table
https://oracle-base.com/articles/8i/import-blob