THanks, Djam
I would like to clarify my question.
Built-in Read_image_file(varchar IN dirname,varchar IN fileExt ,varchar IN imageItemName) can be used to populate image into form image item ,for example, in When-New-Form-Instance trigger. It's allowed to see image in a form if the image is in specified directory.
I would like to insert this image into database if the image item is associated with blob or any other datatype which can be associated with images. The problem is that I don't have a prevelige to create directory and database administrator doesn't want to give it to me.I need it because DBMS_LOB library procedures for inserting images require directory as parameter.
I can avoid using this library by using JDBC or SQL Loader.
The question is whether I can avoid it using inserting images from the form.
To insert the image, the original image has to reside somewhere for the read_image_file to read it to the form. It can reside on the users local machine if you dont have a directory on the server to use. It depends on what your application is doing. for example, if a user is taking photos at his workstation, the read_image_file can look for the photos at the workstation on his local drive somewhere..
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.
I may be wrong, but I think the dbsm_lob package is designed to do more like batch loading of tables with images. You dont have to use dbms_lob on a form to load 1 image into an image_item.
if you put a read_image_file command on a button,
read_image_file('myphoto.jpg','JPG','myblock.my_image');
pressing the button will read the image into the my_image field and store it into the database.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.