|
Re: How can I store picture in database.................. [message #173267 is a reply to message #173241] |
Sun, 21 May 2006 04:43 |
oraclejo
Messages: 50 Registered: July 2005 Location: Ammar
|
Member |
|
|
Assume you have a table called myimages with a field of type blob (image_name, mime_Type,
a procedure should be something likePROCEDURE load_picture (
thefile VARCHAR2) AS
f_lob BFILE;
b_lob BLOB;
image_name VARCHAR2 (30);
mime_type VARCHAR2 (30);
dot_pos NUMBER;
BEGIN
dot_pos := INSTR (thefile, '.');
image_name := filename; --SUBSTR(thefile,1,dot_pos-1);
mime_type := 'image/' || SUBSTR (thefile, dot_pos + 1, length (thefile) );
INSERT INTO myimages
values (image_name,
mime_type,
empty_blob () )
RETURN content
INTO b_lob;
f_lob := BFILENAME ('SOURCE_DIR', thefile);
dbms_lob.fileopen (f_lob, dbms_lob.file_readonly);
dbms_lob.loadfromfile (b_lob, f_lob, dbms_lob.getlength (f_lob) );
dbms_lob.fileclose (f_lob);
end;
Note: Oracle needs to know where the location of the file is, therefore, you need to use the SQL command CREATE DIRECTORY.
Please check the command in Oracle doc for further details
At the form level, there is not much you need to do, just make sure that the item type is image then things should work fine
Ammar Sajdi
Oracle consultant
JORDAN
www.e-ammar.com
www.palco-me.com
[Updated on: Sun, 21 May 2006 23:27] by Moderator Report message to a moderator
|
|
|