Home » Developer & Programmer » Forms » How can I store picture in database..................
How can I store picture in database.................. [message #173241] Sat, 20 May 2006 15:18 Go to next message
imtiazmasud
Messages: 49
Registered: May 2005
Location: Bangladesh
Member

Dear friends,

Can any one of u clearly explain
me how I can store picture in Database

i.e., in Table level.

Then how can I retrieve in Oracle forms.

Please help with details code...I know that I need to use BLOB but how ....please with details.....imtiazmasud
Re: How can I store picture in database.................. [message #173267 is a reply to message #173241] Sun, 21 May 2006 04:43 Go to previous message
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 like
PROCEDURE 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

Previous Topic: SEE MY ERROR :FRM-40735 : WHEN-BUTTON-PRESSED TRIGGER RAISED UNHANDLED EXPCEPTION ORA-00001.
Next Topic: CALLING A VB APPLICATION INTO A FORM
Goto Forum:
  


Current Time: Fri Sep 20 10:29:55 CDT 2024