GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Tech FAQs  >  Oracle
Go To First  |  Previous Question  |  Next Question 
 Oracle  |  Question 189 of 201    Print  
Store Image in Oracle
How to store Image in Oracle table


  
Total Answers and Comments: 1 Last Update: July 08, 2008     Asked by: amplemaddy 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
May 28, 2008 06:44:29   #1  
singh.neerajin Member Since: May 2008   Contribution: 4    

RE: Store Image in Oracle

It is always better to store the images in the BLOB or CLOB datatype.......

PROCEDURE apply_changes_to_illust
(
path varchar2
)
IS

  f_lob BFILE;
  b_lob BLOB;
  image_name VARCHAR2(30);
  dot_pos NUMBER;
  x varchar2(100);
  f utl_file.file_type;
  FileChk VARCHAR2(10) := NULL;
  SCHEMAUSER VARCHAR2(2000);
  Cur VARCHAR2(4000) := NULL;
  IN_PATH varchar2(2000);
  TYPE IMG_NAME IS REF CURSOR;
  IMG_DIFF IMG_NAME;

  z_IMGNAME  ILLUST.ILLUSNAME%TYPE;
  z_IllusID  ILLUST.ILLUSID%TYPE;
 

BEGIN

  execute immediate (' ALTER TRIGGER ILLUST DISABLE ');
  execute immediate ('create or replace directory SOURCE_DIR as '''|| path ||'''');
  CUR:='SELECT ILLUSNAME,ILLUSID FROM ILLUST';

  OPEN IMG_DIFF FOR CUR;
   LOOP
    Fetch IMG_DIFF INTO z_IMGNAME,z_IllusID;
    EXIT When IMG_DIFF%NOTFOUND;
      dot_pos := INSTR(z_IMGNAME,'.');

      image_name := z_IMGNAME || '.tif';
       SELECT file_exists(image_name) INTO FileChk from dual;
       IF FileCHk = 'TRUE' THEN
                  
          
           UPDATE ILLUST SET ILLUSIMAGE = empty_blob() WHERE ILLUSNAME = z_IMGNAME AND ILLUSID= z_IllusID
           RETURN ILLUSIMAGE INTO b_lob;
           f_lob := BFILENAME('SOURCE_DIR', image_name);
           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);
           commit;
           END IF;
    END LOOP;
    execute immediate (' ALTER TRIGGER ILLUST ENABLE ');
END apply_changes_to_illust;


In this code there is a directory where images had been located . This code first checks the existence of images . If  images found then its is loaded in the table.

SOURCE_DIR : it is the directory path where the images are residing. path is a parameter throug which directory path is coming.

image_name : is the name of the image coming through  the cursor.

File_exists : is a function which checks the existence of image_name  under in the root directory:

If image is found then its ia lodaed in the ILLUST table in the;

ILLUSIMAGE : is the column name where image is laoded

flob: is the file name of the image
b_lob: paramneter of BLOB
dbms_lob.fileopen: opens the image file.
dbms_lob.loadfromfile: load the image file .
dbms_lob.fileclose: closes the image file opened.

finally all the images are laoaded.....





 
Is this answer useful? Yes | No

 Related Questions

8060 
Latest Answer : Hi,Rowsize depends up on the no of columns and their size , you can calculate the avg row size using vsize  and maximum we can have 1000 col in table. ...
Read Answers (1) | Asked by : Sabby

Latest Answer : oracle supports two types of joins: 1.oracle joins   cartesian join   equi join   non equi join   self join   outer  join is exhibited using "+" operator    2.ansii ...

Latest Answer : Select * from dba_objects where owner = 'GL' and object_type = 'TABLE'Change GL to AP and AR for respective table info. ...
Read Answers (1) | Asked by : mahendra

Latest Answer : For time being type below command at sql promptSQL>define_editor=viYou can add export EDITOR=vi in .profile and logou/login for permament changeHope this will solve it ...
Read Answers (3) | Asked by : haisubbu

I am creating one table in oracle. in database it is allocated some memory for that table. how can i know how much memory that table is holding in that database?

Latest Answer : ANY and ALL are Multiple row operators.ANY - Greater than the MinimumALL - Greater than the maximum  ...

Latest Answer : most of our friends have given different answers for this..........infact most of them are same and correct .......but I will give one simple definition and small logic beyond its working.........? I can say it is a practise table as it contains ...
Read Answers (9) | Asked by : Sundra

Latest Answer : when a commit occurs in the transaction then the points are as mentioned:-1)an SCN is created & record in redo log buffer2)LGWR writes from Redo log buffer to redo log files3)oracle shows commit complete4)locks now can be released ...

How to store a bitmap or jpeg file on oracle database?which datatype is used and what is the retrival method ?

Latest Answer : Installation of ORACLE 9i in LinuxRefer this page http://ivan.kartik.sk/oracle/install_ora9_elinux.html#st1 ...
Read Answers (1) | Asked by : megh


 Sponsored Links

 
Related Articles

Querying Data with Oracle XQuery

Querying Data with Oracle XQuery Starting with Oracle Database 10g Release 2 you can take advantage of a full featured native XQuery engine integrated with the database With Oracle XQuery you can accomplish various tasks involved in developing PHP Oracle XML applications operating on any kind of dat
 

Using Oracle XML DB Repository

Using Oracle XML DB Repository Another variation on accessing and manipulating XML content stored in Oracle database is provided by Oracle XML DB repository which is an essential component of Oracle XML DB mosgoogle NOTE Oracle XML DB repository also known as XML repository is a hierarchically organ
 

Using Oracle Database for Storing, Modifying, and Retrieving XML Data

Using Oracle Database for Storing Modifying and Retrieving XML Data With Oracle XML DB you have various XML storage and XML processing options allowing you to achieve the required level of performance and scalability One of the most interesting things about Oracle XML DB is that it allows you to per
 

XML Processing in PHP and Oracle Applications

Processing XML in PHP Oracle Applications As mentioned there are two alternatives when it comes to performing XML processing in your PHP Oracle application You can perform any required XML processing using either PHP s XML extensions or PEAR XML packages or Oracle s XML features mosgoogle In the fol
 

PHP Oracle Web Development

PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax The book is written by Yuli Vaseliev a well known author of different web development and programming books PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax is a good starting b
 

Getting Started with Oracle and ODP.NET

ODP NET Developer’ s Guide by Jagadish Chatarji Pulakhandam Sunitha Paruchuri A practical guide for developers working with the Oracle Data Provider for NET and the Oracle Developer Tools for Visual Studio 2005 Application development with ODP NET Dealing with XML DB using ODP NET Oracle
 

PHP Oracle Web Development Review

PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax The book is written by Yuli Vaseliev a well known author of different web development and programming books The author is also an expert in open source technologies and SOA Service Oriented Architecture But besides
 

Step by Step Oracle PL-SQL Tutorial

This introductory tutorial to PL SQL will help you to understand the basic concepts of PL SQL Please review the following tutorials and practice the sample SQL Statements on your local Oracle Database Please note that you must learn these basic things before we actually start getting in to Advanced
 

Working with XML in Oracle

Working with XML in Oracle Introduction to XML Extensive markup language is the language which presents data in a human readable form of text The data can be anything from a purchase order or a stock quote or weather radar or a flight schedule it can be represented using XML XML is very similar to H
 

What is Operational Data Store (ODS)

An Operational Data Store (ODS) is an integrated database of operational data. Its sources include legacy systems and it contains current or near term data. An ODS may contain 30 to 60 days of information, while a data warehouse typically contains years of data. An operational data store is basica
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape