Inserting the image

How can I insert an image into oracle database?

Questions by penchalarao.s

Showing Answers 1 - 3 of 3 Answers

Mythili karanam

  • Aug 9th, 2011
 

1)Create one directory in OS(Operating System)
Place all the images in this directory
2) create one directory in data base with the link of this os directory
eg:E:ordb

Create table images(img_name varchar2(30),mime_type varchar2(30),content blob);

Code

  1. Load(filename VARCHAR2)


  2. f_lob bfile;

  3. B-lob blob;


  4.    INSERT INTO images

  5.    VALUES(filename,SUBSTR(filename,INSTR(filename,'.')+1),EMPTY_BLOB());

  6. RETURN content INTO b_lob;

  7. f_lob:=BFILENAME('ordb',fielanme);

  8. DBMS_LOB.fileopen(f_lob,DBMS_LOB.file_readonly);

  9. DBMS_LOB.loadfromfile(b_lob,f_lob,DBMS_LOB.getlength(f_lob));

  10. DBMS_LOB.fileclose(f_lob);


  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions