Regarding a post on oracle forum bout how to store image files in database using insert command. Actually, I don’t know it is running well or not cause I haven’t test it yet but I just kept this for documentation. Sometimes I’ll explore it when I needed. Please give me a notes if You had already try it.
Here is the script.
CREATE TABLE MY_IMAGE_TABLE (
CREATE OR REPLACE DIRECTORY IMAGES AS ‘/tmp’;
GRANT READ, WRITE ON DIRECTORY IMAGES TO PUBLIC;
CREATE OR REPLACE PROCEDURE load_file_to_my_table (p_file_name IN MY_IMAGE_TABLE.NAME%TYPE) AS
INSERT INTO MY_IMAGE_TABLE (id, name, image)
VALUES (1, p_file_name, empty_blob())
RETURN doc INTO v_blob;
v_bfile := BFILENAME(‘IMAGES’, p_file_name);
Dbms_Lob.Loadfromfile(v_blob, v_bfile, Dbms_Lob.Getlength(v_bfile));