This is a PL/SQL code which allows insert image from specified directory and it requires a dbms_lob library and previlige to create directory as a database object.
REM
REM Create the directory
create or replace directory BLOBDIR as '/app/oradata/blobdir';
REM Create the Table
create table blobtab
(REFNO NUMBER(3),
BLOB_DATA BLOB);
REM Insert a dummy row
insert into blobtab values
('001',empty_blob());
REM Run the Procedure to insert the image
contaict set serveroutput on
declare
ablob blob;
abfile bfile := bfilename('BLOBDIR','the_name_of_your_image.jpg');
amount integer;
asize integer;
begin
select blob_data into ablob from blobtab where refno='001'
for update;
dbms_lob.fileopen(abfile);
asize := dbms_lob.getlength(abfile);
dbms_output.put_line('Size of input file: ' || asize);
dbms_lob.loadfromfile(ablob, abfile, asize);
dbms_output.put_line('After loadfromfile');
asize := dbms_lob.getlength(ablob);
dbms_output.put_line('Size of blob: ' || asize);
exception
when others then
dbms_output.put_line('An exception occurred');
dbms_output.put_line(sqlcode || sqlerrm);
end;
/
I have an Oracle Form which has a data block based on database table with field varchar for directory and Blob for image. This block contains buttom which allows to populate image into Image item. When I save record - just directory is saved in database.
I am wondering whether I can avoid insertind code somewhere in a form , similar to above, and be able to save image.
velena