5 Replies Latest reply: Mar 20, 2011 9:18 PM by 848893 RSS

    How to insert image into table and to in Oracle 9i intermedia?

    452516
      Mr Lawrence,
      I want to ask something:
      I use Oracle 9i intermedia
      If i use this script:

      CREATE TABLE images (
      file_name VARCHAR2(100) NOT NULL,
      image ORDSYS.OrdImage
      );

      then

      CREATE OR REPLACE DIRECTORY imgdir AS 'd:/data';

      then

      INSERT INTO images (file_name, image)
      VALUES ('tree', ORDSYS.ORDImage.init('file','imgdir','tree.jpg' ));

      I put tree.jpg in directory d:/data in my hard drive.
      Is my tree.jpg file had already get in to my images table?

      I'm little confuse, because when i check my table with this script:


      select file_name, i.image.getWidth() from images i;

      it's show that my i.image.getWidth() for file_name tree is empty.. that mean my tree.jpg doesn't get in to my table.. am i correct?

      N also i want to ask how to display to screen all of my image from images table?
      Is it posible Oracle 9i intermedia to support display image from table?
      How?

      thanks Mr Lawrence
        • 1. Re: How to insert image into table and to in Oracle 9i intermedia?
          156916
          You need to read the documentation.

          You need to call the import() procedure (which indirectly calls setProperties()).

          See:

          http://www.oracle.com/technology/products/intermedia/index.html
          http://www.oracle.com/technology/sample_code/products/intermedia/htdocs/bulkload.html
          http://download-west.oracle.com/docs/html/B14302_01/toc.htm
          http://download-west.oracle.com/docs/html/B14297_01/toc.htm

          As for displaying the images, it all depends on what environment you are using. c++? Java? PL/SQL? OCCI? PHP? Web? Streaming server?..... I can't even begin to answer.

          Larry
          • 2. Re: How to insert image into table and to in Oracle 9i intermedia?
            588108
            How to insert image into table as a data in Oracle 9i
            • 3. Re: How to insert image into table and to in Oracle 9i intermedia?
              408591
              Create a coulmn as BLOB datatype in the table, then import the data using InterMedia procedure into the table.
              • 4. Re: How to insert image into table and to in Oracle 9i intermedia?
                Aparna16
                -- First step would be to create a directory in oracle and map it to the folder where your image resides.

                create directory image_dir as *'c:\image_dir';*

                Then you would have to use a procedure to insert the image in your table. SO first create a table to hold the image. Note that you have to use a BLOB to insert the image.

                -----
                CREATE TABLE test_image
                (
                ID NUMBER,
                image_filename VARCHAR2(50),
                image BLOB
                );
                -----
                Now let's write the procedure to insert the image in the table above.

                -----
                CREATE OR REPLACE PROCEDURE insert_image_file (p_id NUMBER, p_image_name IN VARCHAR2)
                IS
                src_file BFILE;
                dst_file BLOB;
                lgh_file BINARY_INTEGER;
                BEGIN
                src_file := BFILENAME ('image_DIR', p_image_name);

                -- insert a NULL record to lock
                INSERT INTO temp_image
                (ID, image_name, image
                )
                VALUES (p_id, p_image_name, EMPTY_BLOB ()
                )
                RETURNING image
                INTO dst_file;

                -- lock record
                SELECT image
                INTO dst_file
                FROM temp_image
                WHERE ID = p_id AND image_name = p_image_name
                FOR UPDATE;

                -- open the file
                DBMS_LOB.fileopen (src_file, DBMS_LOB.file_readonly);
                -- determine length
                lgh_file := DBMS_LOB.getlength (src_file);
                -- read the file
                DBMS_LOB.loadfromfile (dst_file, src_file, lgh_file);

                -- update the blob field
                UPDATE temp_image
                SET image = dst_file
                WHERE ID = p_id AND image_name = p_image_name;

                -- close file
                DBMS_LOB.fileclose (src_file);
                END insert_image_file;

                -----
                Now execute the procedure to insert the image.

                EXECUTE insert_image_file(1,'test_image.jpg');


                Thanks,
                Aparna
                • 5. Re: How to insert image into table and to in Oracle 9i intermedia?
                  848893
                  irwan_thio wrote:

                  Mr Lawrence,

                  I want to ask something:

                  I use Oracle 9i intermedia

                  If i use this script:



                  CREATE TABLE images (

                  file_name VARCHAR2(100) NOT NULL,

                  image ORDSYS.OrdImage

                  );



                  then



                  CREATE OR REPLACE DIRECTORY imgdir AS 'd:/data';



                  then



                  INSERT INTO images (file_name, image)

                  VALUES ('tree', ORDSYS.ORDImage.init('file','imgdir','tree.jpg' ));



                  I put tree.jpg in directory d:/data in my hard drive.

                  Is my tree.jpg file had already get in to my images table?



                  I'm little <font face="tahoma,verdana,sans-serif" size="1" color="#000">confuse</font>, because when i check my table with this script:



                  <P>select file_name, i.image.getWidth() from images i;



                  it's show that my i.image.getWidth() for file_name tree is empty.. that mean my tree.jpg doesn't get in to my table.. am i correct?



                  N also i want to ask how to display to screen all of my image from images table?

                  Is it posible Oracle 9i intermedia to support display image from table?

                  How?



                  thanks Mr Lawrence</P>
                  Could you give more specific decription? I still have no idea about what you said.