how to retrieve the image one by one from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sramasami
    New Member
    • Oct 2007
    • 2

    how to retrieve the image one by one from database

    hi

    im doing project in image mining..... how to store image in oracle database...
    and how to retrieve one by one from image database..pleas e help me... i need a sample code... pls reply to this
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to Oracle Forum.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      To store image in oracle use LONG RAW data type.

      To store the image convert it into binary stream and store in database and vice versa to retrive.

      Comment

      • rahulkoshti
        New Member
        • Jan 2008
        • 5

        #4
        You can use SQL Loader to load number of image files.
        The code for this is as follows:

        LOAD DATA
        INFILE *
        INTO TABLE image_table
        FIELDS TERMINATED BY ","
        (
        image_id INTEGER(5),
        file_name CHAR(30),
        image_data LOBFILE (file_name) TERMINATED BY EOF
        )
        BEGINDATA
        001,1.gif

        Image file shoud be in a admin folder from where you are executing
        SQLLDR command...

        Comment

        • subashsavji
          New Member
          • Jan 2008
          • 93

          #5
          Originally posted by sramasami
          hi

          im doing project in image mining..... how to store image in oracle database...
          and how to retrieve one by one from image database..pleas e help me... i need a sample code... pls reply to this

          create or replace directory ctemp as 'c:\';
          /

          CREATE TABLE pdm (
          dname VARCHAR2(30), -- directory name
          fname VARCHAR2(30), -- file name
          iblob BLOB) -- image file
          /

          CREATE OR REPLACE PROCEDURE load_file (
          pdname VARCHAR2,
          pfname VARCHAR2) IS
          src_file BFILE;
          dst_file BLOB;
          lgh_file BINARY_INTEGER;
          BEGIN
          src_file := bfilename('CTEM P', pfname);
          -- insert a NULL record to lock
          INSERT INTO pdm
          (dname, fname, iblob)
          VALUES
          (pdname, pfname, EMPTY_BLOB())
          RETURNING iblob INTO dst_file;
          -- lock record
          SELECT iblob
          INTO dst_file
          FROM pdm
          WHERE dname = pdname
          AND fname = pfname
          FOR UPDATE;
          -- open the file
          dbms_lob.fileop en(src_file, dbms_lob.file_r eadonly);
          -- determine length
          lgh_file := dbms_lob.getlen gth(src_file);
          -- read the file
          dbms_lob.loadfr omfile(dst_file , src_file, lgh_file);
          -- update the blob field
          UPDATE pdm
          SET iblob = dst_file
          WHERE dname = pdname
          AND fname = pfname;
          -- close file
          dbms_lob.filecl ose(src_file);
          END load_file;
          /
          EXECUTE load_file('CTEM P','zak.gif');
          /

          note:- file 'zak.gif' must be exist in c:\ drive.
          after this you use any frontend tool to retrieve image. e.g. dk2 6i/ 9i
          you can not fetch the image in oracle.

          Comment

          Working...