How to insert images into oracle databse......

hi,
i have to insert images into oracle database..
but we have a procedure to insert images into oracle database..
how to execute procedure.
my images file is on desktop.
i am using ubuntu linux 8.04..
here i am attaching code of my procedure
create or replace PROCEDURE INSERT_BLOB(filE_namE IN VARCHAR2,dir_name varchar2)
IS
tmp number;
f_lob bfile;
b_lob blob;
BEGIN
dbms_output.put_line('INSERT BLOB Program Starts');
dbms_output.put_line('--------------------------');
dbms_output.put_line('File Name :'||filE_namE);
dbms_output.put_line('--------------------------');
UPDATE photograph SET image=empty_blob()
WHERE file_name =filE_namE
returning image INTO b_lob;
f_lob := bfilename( 'BIS_IMAGE_WORKSPACE',filE_namE);
dbms_lob.fileopen(f_lob,dbms_lob.file_readonly);
--dbms_lob.loadfromfile(b_lob,f_lob,dbms_lob.getlength(f_lob));              
insert into photograph values (111,user,sysdate,b_lob);
dbms_lob.fileclose(f_lob);
dbms_output.put_line('BLOB Successfully Inserted');
dbms_output.put_line('--------------------------');
commit;
dbms_output.put_line('File length is: '||dbms_lob.getlength( f_lob));
dbms_output.put_line('Loaded length is: '||dbms_lob.getlength(b_lob));
dbms_output.put_line('BLOB Committed.Program Ends');
dbms_output.put_line('--------------------------');
END inserT_bloB;
warm regerds
pydiraju
please solve my problem
thanks in advance.......

thank you
but i am getting the following errors.
i connected as dba and created directory on /home/pydiraju/Desktop/PHOTO_DIR'
and i gave all permissions to scott user.
but it not working . it gives following errors.
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
Permission denied
ORA-06512: at "SYS.DBMS_LOB", line 523
ORA-06512: at "SCOTT.LOAD_FILE", line 28
ORA-06512: at line 1
Warm regards,
Pydiraju.P
Mobile: +91 - 9912380544

Similar Messages

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

    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

    -- 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

  • Use scanner or/and camera to insert image into oracle database BLOB feild

    can any body show how i can do these? send me an example to do this?
    notice: i'am using oracle form 6i & oracle databse 10g
    best regards
    hamdan
    Edited by: user633386 on 05/07/2011 11:57 م

    It's been discussed now and then. Hope this helps:
    Insert Picture (image) using oracle forms
    Looks like a keyword to search on is read_image_file
    This all assumes that we know the name of the file.

  • How to insert data into Oracle db from MySQL db through PHP?

    Hi,
    I want to insert my MySQL data into Oracle database through PHP.
    I can access Mysql database using mysql_conect() & Oracle database using oci_connect() through PHP.
    Now How can I insert my data which is in MySQL into Oracle table. Both table structure are exactly same.
    So I can use
    insert into Oracle_Table(Oracle_columns....) values(Select * from MySQL_Table);
    But again problem is I can't open both connections at the same time.
    So has anyone done this before or anyone having any other idea..
    Plz guide me...

    You can do it if you setup a ODBC Gateway between MYSQL and Oracle DB. Then you can directly read from MySQL table using DB links and insert into Oracle table in one single SQL Statement.
    Otherwise you need to fetch the data from MySQL Into variables in your PHP Program and then insert into Oracle after binding the variables to the insert statement for Oracle. Hope that is clear enough.
    Regards
    Prakash

  • How to insert date into oracle database

    Hi, there,
    I want to insert date information to oracle database in a jsp page using JSTL. but always got wrong message:
    javax.servlet.jsp.JspException:
    INSERT INTO DATE_TEST
    (date_default,date_short,date_medium)
    values(?,?,?)
    : Invalid column type
    I don't know how to convert java date type to oracle date type or vice versa. the following is the source code(all the fields of DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM are oracle date type. and even I want to insert d instead d1, I got the same wrong message)
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.util.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
    <%
    Calendar now;
    Calendar rightNow = Calendar.getInstance();
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>
    Hello World
    </title>
    </head>
    <body>
    <h2>
    The current time is:
    </h2>
    <p>
    <%= new java.util.Date() %></p>
    <%
    java.util.Date d=new java.util.Date();
    java.sql.Date d1=new java.sql.Date(d.getYear(),d.getMonth(),d.getDate());
    out.print(d1.toString());
    %>
    <sql:update>
    INSERT INTO DATE_TEST
    (DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM)
    VALUES(?,?,?)
    <sql:dateParam value="${d}" type="date" />
    <sql:dateParam value="${d}" type="date" />
    <sql:dateParam value="${d}" type="date" />
    </sql:update>
    </body>
    </html>
    thank you very much for the great help!!

    Hi, there,
    I want to insert date information to oracle database in a jsp page using JSTL. but always got wrong message:
    javax.servlet.jsp.JspException:
    INSERT INTO DATE_TEST
    (date_default,date_short,date_medium)
    values(?,?,?)
    : Invalid column type
    I don't know how to convert java date type to oracle date type or vice versa. the following is the source code(all the fields of DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM are oracle date type. and even I want to insert d instead d1, I got the same wrong message)
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.util.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
    <%
    Calendar now;
    Calendar rightNow = Calendar.getInstance();
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>
    Hello World
    </title>
    </head>
    <body>
    <h2>
    The current time is:
    </h2>
    <p>
    <%= new java.util.Date() %></p>
    <%
    java.util.Date d=new java.util.Date();
    java.sql.Date d1=new java.sql.Date(d.getYear(),d.getMonth(),d.getDate());
    out.print(d1.toString());
    %>
    <sql:update>
    INSERT INTO DATE_TEST
    (DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM)
    VALUES(?,?,?)
    <sql:dateParam value="${d}" type="date" />
    <sql:dateParam value="${d}" type="date" />
    <sql:dateParam value="${d}" type="date" />
    </sql:update>
    </body>
    </html>
    thank you very much for the great help!!

  • Insert data into oracle table from XML file

    I need to insert data into oracle table from XML file
    If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
    Thanks in advance

    The XML DB forum provides the best support for XML topics related to Oracle.
    Here's the FAQ on that forum:
    XML DB FAQ
    where there are plenty of examples of shredding XML into Oracle tables and such like. ;)

  • How to Insert Hastables Into Database Through JDBC

    hi all,
    I have place the Data from the Hashtables Into the Database.I can place it by Iterating through the Hastables.I would Like to Place the Entire Hashtable Itself Into the Database.
    Can Any one tell me how?
    bye.

    Hi,
    Can anyone help me out how to insert image into
    database using struts...with dao n dto classes?If it matters whether or not you are using struts then you might have something wrong.
    Make sure you separate the database logic out.
    I know these types of questions are asked frequently, you might want to search the forum for additional examples.
    Here is a good one:
    http://forum.java.sun.com/thread.jspa?threadID=620455&messageID=3495899

  • Inserting image into table

    hi,
    i m create table, then create procedure, procedure is successfully compile, but when i m trying to insert image into table it error out.
    for inserting image i go with
    EXECUTE insert_image_file(1,'C:\sunset.jpg');
    sunset.jpg is image which i want to insert in table, and which is present on 'c drive'.
    when execute the following error are shown
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 635
    ORA-06512: at "SCOTT.INSERT_IMAGE_FILE", line 26
    ORA-06512: at line 1
    how to solve it.
    regards
    prashant

    Prashant wrote:
    CREATE OR REPLACE PROCEDURE insert_image_file (p_id NUMBER, p_image_name IN VARCHAR2)
    ...snipped...Not very nice code... why create an empty image row, then lock it (it is already locked by the uncommitted insert statement), and then update it again? Not very efficient or sensible.
    image is on local machine.When a row is created on the server from user input on some PC, who supplied that input? Who read the user's keyboard input on that PC to obtain the values for the columns for the row to create?
    Did PL/SQL read the keyboard of that remote PC? Of course not. The client program on that PC read the keyboard input. It then made a client call to the Oracle server. It supplied the data entered via the keyboard by the user to the Oracle server (using a PL/SQL call or using a SQL statement call to Oracle).
    Now why would a local image data on that PC be treated any differently than the keyboard data on that PC? How can you expect PL/SQL code running on the Oracle server, to read that image data from the remote PC when the same PL/SQL code is incapable of reading keyboard input from that very same PC?
    You need to review your understanding of client-server and how it pertains to using Oracle within client-server architecture.

  • Inserting Image into a BLOB column in Oracle9i

    Hi,
    I am unable to insert image into a BLOB column. I am using Forms 6i REL 2 and Oracle 9i. But I could do it on Oracle 8i with same Forms version.
    Same thing is true for CLOB in 9i.
    Would you please try with this code?
    TABLE
    Create table x
    (Id number,
    Name CLOB,
    Pict BLOB);
    WHEN-BUTTON-PRESSED trigge
    declare
         x varchar2(265);
    begin
         x := get_file_name;
         read_image_file (x, 'GIF', 'picture.pict');
    end;
    Take care,
    Tarek

    Forms 9i and Oracle 9i work fine together for this case.

  • How to insert images in a table

    Hi all,
    Iam working On Oracle10g
    can any one explain how to insert images in a table.
    Any help will be much appreciated!!
    Thanks.

    Hi,
    Try like this
    step1: Create a folder & place the image in it.
    for eg: place the image 'Sunset.jpg' in 'IMAGEFILE' folder of D drive
    Step2: Create a Directory in sql*plus as
    CREATE DIRECTORY IMAGEDIR AS 'D:\IMAGEFILE';
    Step3: Grant previlage to user
    GRANT READ ON DIRECTORY IMAGEDIR TO PUBLIC;
    Step4: Create the table in which you want to insert the image
    create table loadalbum
    (name varchar2(100),
    image blob)
    Step5: Create the procedure as
    declare
    l_blob blob;
    l_bfile bfile;
    begin
    insert into loadalbum values ( 'Sunset', EMPTY_BLOB() )
    returning image into l_blob;
    l_bfile := bfilename( 'IMAGEDIR', 'Sunset.jpg');
    dbms_lob.fileopen( l_bfile );
    dbms_lob.loadfromfile( l_blob, l_bfile, dbms_lob.getlength( l_bfile ) );
    dbms_lob.fileclose( l_bfile );
    end;
    Now you can know whether the image is inserted or not by
    SELECT COUNT(*) FROM LOADALBUM;
    COUNT(*)
    1
    which means image is inserted.
    Hope this may help you.

  • How to Insert image file from fileChooser to a tabbedPane?

    Hi,
    Currently, i have encounted a problem halfway through my project. That is how do i insert images into a tabbedPane after selecting a image file from the fileChooser?
    Do anyone has any idea of how to solve the above problem?
    Thanks!!

    I would put the image in a JLabel and put the JLabel in the tabbed pane.

  • Inserting images into form.

    Hi, i am new to midlet programming.
    Can anybody help me in inserting images into forms.
    And how do we set a thumbnail view in a form.
    Thanks.

    Hello,
    use
    Image tmp = Image.CreateImage ("/com/...../t.jpg");
    Form f = new Form ("title here");
    f.append (tmp);
    //if u want to insert it after loading the form use
    f.insert (index,tmp);
    Good Luck,
    Rawad

  • How can store .gif into oracle ?

    Hai,
    when i am inserting .gif file into oracle,i getting the sql error message at run time like java.sql.sqlException [oracle][odbc]No data at execution values pending.
    I have placed a valid .gif file path ,while i have creating file objct.
    i have used below the coding to insert .gif into oracle,
    Demox.java
    public class Demox
    public static void main(String x[])
    ResultSet rs;
    Connection con;
    Statement st,st1;
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:mydsn","scott","cipl");
    st=con.createStatement();
    File file = new File("c:/mahesh/oracle.gif");
    System.out.println("file cotent is"+file);
    InputStream inStream = new FileInputStream(file);
    System.out.println("before prepstmt");
    PreparedStatement psmt =con.prepareStatement("INSERT INTO + demo(id,pict)VALUES(?,?)");
    psmt.setString(1, "Logo");
    psmt.setBinaryStream(2, inStream, (int)file.length());
    psmt.execute();
    //HRER ONLY I GOT THE ERROR MSG LIKE [oracle][odbc]No data at execution values pending.//
    System.out.println("after execute");
    if(psmt != null)
    psmt.close();
    if(con != null)
    con.close();
    catch(Exception q)
    {System.out.println("Hai:"+q);}
    In database i have used long raw datatpe to store .gif file,meanwhile
    I have tried blob as datatype to store .gif,still i got the same exception
    :[oracle][odbc]No data at execution values pending....
    So,any one could me out from this probs.It's little bit urgent....
    Regards,
    mahesh.

    Hi
    Instead of storing the file in the database. Store the image in a file on the disk and store the path to the image in your database. This is one good way of doing this.
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • How I take image into showOneTab?

    hi all
    i want to show image instead label text in ShowDetailTab component and I already set background-image to inlinestyle but the image doesn'tshow if the label text is blank
    pleas help me
    Thank you for your kindness...... = (^ . ^ )=

    hi,
    i think you cnt insert image into a blob type column
    you may have to put the path in the column and store the images on to the path on some server....
    check out this link
    http://www.oracle.com/technology/products/intermedia/htdocs/intermedia_quickstart/intermedia_rel_quickstart.html

  • How to insert data into the mysql table by giving as a text file

    Hi,
    Any one know's how to insert data into the mysql table by giving as a text file as the input in JSP.Please respond ASAP.
    Thanks:)

    At least you can try StringTokenizer to parse your text files. Or download a text JDBC driver to parse your files, for instance, HXTT Text(www.hxtt.net) or StelsCSV(www.csv-jdbc.com).

Maybe you are looking for

  • XSLT Mapping - help

    Hi All, I am new to XSLT mapping. My requirement is: file to XML file with CDATA, for this I am planning to use the XSLT Mapping. I downloaded the Stylus studio, then what next, Please help meu2026 In source flat file I have 5 fileds, and target I ne

  • Limiting the number of files being picked up by the sender file adapter

    We are running a file adapter to collect xml files from a legacy system in a shared network location.  The files are picked up, information is sorted and mapped, and then sent to a proxy on our CRM system to store the data.  Very simple and not-compl

  • Problem with- FWZZ(BDC)

    hi i am trying to use bdc for uploading mutual fund dividend (tcode-FWZZ). actually two tables VZZKOPO & VWBEPP gets updated when we run the transaction.But when i am running my bdc only one table is getting updated i.e VZZKOPO.why it is happenig lik

  • Problem with french character display in Excel file

    In my program I am exporting the french content into one excel file (.csv)through the following code but the characters in french are not getting displayed properly. Please let me know what is the issue I have checked the contents that is being writt

  • How I solved my audio/video ichat problem

    Hope to be useful to somebody. I just had to disable the internet sharing and voila, everything is working well now.