I need to read every file of an Oracle Directory (without knowing the name) and update a BLOB column with the file if the name of the file match with the PK table.
TABLE_TEST
ID NUMBER(10,0) PK
FOTO BLOB NULL
I did a PL/SQL function to read one file (knowing the name) and update the table with the BLOB, which works correctly. But, I don't know how I could read every file without knowing the name and take the name of the file.
DECLARE
l_blob BLOB;
v_src_loc BFILE := BFILENAME ('IMAGE_FILES8', '4.PNG');
v_amount INTEGER;
BEGIN
UPDATE TABLE_TEST
SET FOTO = EMPTY_BLOB ()
WHERE ID = 4
RETURN FOTO
INTO l_blob;
DBMS_LOB.OPEN (v_src_loc, DBMS_LOB.LOB_READONLY);
v_amount := DBMS_LOB.GETLENGTH (v_src_loc);
DBMS_LOB.LOADFROMFILE (l_blob, v_src_loc, v_amount);
DBMS_LOB.CLOSE (v_src_loc);
COMMIT;
END;