How to insert an image file in Oracle database

hi
can you please tell me how to insert an image file into oracle database????
suppose there is one image file in c:\pictures\rose.jpg. how to insert that file into database? theoretically i know that will be BFILE type but i dont know how to insert that.
will be waiting for your reply........
thanks & regards,
Priyatosh

Hello,
The easiest way to load a blob is to use SQL loader.
This example comes from the utilities guide:
LOAD DATA
INFILE 'sample.dat'
INTO TABLE person_table
FIELDS TERMINATED BY ','
(name CHAR(20),
1 ext_fname FILLER CHAR(40),
2 "RESUME" LOBFILE(ext_fname) TERMINATED BY EOF)
Datafile (sample.dat)
Johny Quest,jqresume.txt,
Speed Racer,'/private/sracer/srresume.txt',
Secondary Datafile (jqresume.txt)
Johny Quest
500 Oracle Parkway
Secondary Datafile (srresume.txt)
Loading LOBs
10-18 Oracle Database Utilities
Speed Racer
400 Oracle Parkway
regards,
Ivo

Similar Messages

  • How to insert a image file into oracle database

    hi all
    can anyone guide me how to insert a image file into oracle database now
    i have created table using
    create table imagestore(image blob);
    but when inserting i totally lost don't know what to do how to write query to insert image file

    Hi I don't have time to explain really, I did have to do this a while ago though so I will post a code snippet. This is using the commons file upload framework.
    Firstly you need a multi part form data (if you are using a web page). If you are not using a web page ignore this bit.
    out.println("<form name=\"imgFrm\" method=\"post\" enctype=\"multipart/form-data\" action=\"FileUploadServlet?thisPageAction=reloaded\" onSubmit=\"return submitForm();\"><input type=\"FILE\" name=\"imgSource\" size='60' class='smalltext' onKeyPress='return stopUserInput();' onKeyUp='stopUserInput();' onKeyDown='stopUserInput();' onMouseDown='noMouseDown(event);'>");
    out.println("   <input type='submit' name='submit' value='Submit' class='smalltext'>");
    out.println("</form>"); Import this once you have the jar file:
    import org.apache.commons.fileupload.*;Now a method I wrote to upload the file. I am not saying that this is correct, or its the best way to do this. I am just saying it works for me.
    private boolean uploadFile(HttpServletRequest request, HttpSession session) throws Exception {
            boolean result = true;
            String fileName = null;
            byte fileData[] = null;
            String fileUploadError = null;
            String imageType = "";
            String error = "";
            DiskFileUpload fb = new DiskFileUpload();
            List fileItems = fb.parseRequest(request);
            Iterator it = fileItems.iterator();
            while(it.hasNext()){
                FileItem fileItem = (FileItem)it.next();
                if (!fileItem.isFormField()) {
                    fileName = fileItem.getName();
                    fileData = fileItem.get();
                    // Get the imageType from the filename extension
                    if (fileName != null) {
                        int dotPos = fileName.indexOf('.');
                        if (dotPos >= 0 && dotPos != fileName.length()-1) {
                            imageType = fileName.substring(dotPos+1).toLowerCase();
                            if (imageType.equals("jpg")) {
                                imageType = "jpeg";
            String filePath = request.getParameter("FILE_PATH");
            session.setAttribute("filePath", filePath);
            session.setAttribute("fileData", fileData);
            session.setAttribute("fileName", fileName);
            session.setAttribute("imageType", imageType);
            return result;  
         } And now finally the method to actually write the file to the database:
    private int writeImageFile(byte[] fileData, String fileName, String imageType, String mode, Integer signatureIDIn, HttpServletRequest request) throws Exception {
            //If the previous code found a file that can be uploaded then
            //save it into the database via a pstmt
            String sql = "";
            UtilDBquery udbq = getUser(request).connectToDatabase();
            Connection con = null;
            int signatureID = 0;
            PreparedStatement pstmt = null;
            try {
                udbq.setUsePreparedStatements(true);
                con = udbq.getPooledConnection();
                con.setAutoCommit(false);
                if((!mode.equals("U")) || (mode.equals("U") && signatureIDIn == 0)) {
                    sql = "SELECT SEQ_SIGNATURE_ID.nextval FROM DUAL";
                    pstmt = con.prepareStatement(sql);
                    ResultSet rs = pstmt.executeQuery();
                    while(rs.next()) {
                       signatureID = rs.getInt(1);
                    if (fileName != null && imageType != null) {
                        sql = "INSERT INTO T_SIGNATURE (SIGNATURE_ID, SIGNATURE) values (?,?)";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setInt(1, signatureID);
                        pstmt.setBinaryStream(2, is2, (int)(fileData.length));
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
                if(mode.equals("U") && signatureIDIn != 0) {
                    signatureID = signatureIDIn.intValue();
                    if (fileName != null && imageType != null) {
                        sql = "UPDATE T_SIGNATURE SET SIGNATURE = ? WHERE SIGNATURE_ID = ?";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setBinaryStream(1, is2, (int)(fileData.length));
                        pstmt.setInt(2, signatureID);
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
            } catch (Exception e) {
                con = null;
                throw new Exception(e.toString());
            return signatureID;
       }

  • How to fetch the image file from oracle database and display it.

    hi... i've inserted the image file into the oracle database... now i want to retreive it and want to display it... can anybody help me... pls

    not a big deal dude... i fetched the image from database and saved it into my local hard disk.. but when tried to open it,ends up with no preview... dont know what d prob is... any idea... i've inserted the image as bytes n trying to fetch it as binary stream.. is that the problem... here im giving my insertion and retireving code.. jus go through it...
    Insertion code:_
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package PMS;
    import java.io.File;
    import java.io.FileInputStream;
    import java.sql.Blob;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    public class Browse_java
    static Connection con=null;
    public static void main(String args[])
    try{
    System.out.println("(browse.java) just entered in to the class");
    con = new PMS.DbConnection().getConnection();
    System.out.println("(browse.java) connection string is"+con);
    PreparedStatement ps = con.prepareStatement("INSERT INTO img_exp VALUES(?,?)");
    System.out.println("(browse.java) prepare statement object is"+ps);
    File file =new File("E:/vanabojanalu-/DSC02095.JPG");
    FileInputStream fs = new FileInputStream(file);
    System.out.println("lenth of file"+file.length());
    byte blob[]=new byte[(byte)file.length()];
    System.out.println("lenth of file"+blob.length);
    fs.read(blob);
    ps.setString(1,"E:/vanabojanalu-/DSC02095.JPG");
    ps.setBytes(2, blob);
    // ps.setBinaryStream(2, fs,(int)file.length());
    System.out.println("(browse.java)length of picture is"+fs.available());
    int i = ps.executeUpdate();
    System.out.println("image inserted successfully"+i);
    catch(Exception e)
    e.printStackTrace();
    finally
    try {
    con.close();
    } catch (SQLException ex) {
    ex.printStackTrace();
    and Retrieving code is:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package PMS;
    import java.beans.Statement;
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import oracle.jdbc.OracleResultSet;
    * @author Administrator
    public class view_image2 extends HttpServlet {
    * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("image/jpeg");
    //PrintWriter out = response.getWriter();
    try
    javax.servlet.http.HttpServletResponse res=null;;
    int returnValue = 0;
    Connection con = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
    InputStream in = null;
    OutputStream os = null;
    Blob blob = null;
    //String text;
    //text=request.getParameter("text");
    //Class.forName("com.mysql.jdbc.Driver");
    con=new PMS.DbConnection().getConnection();
    System.out.println("jus entered the class");
    //String query = "SELECT B_IMAGE FROM img_exp where VC_IMG_PATH=?";
    //conn.setAutoCommit(false);
    PreparedStatement pst = con.prepareStatement("select b_image from img_exp where vc_img_path=?");
    System.out.println("before executing the query");
    pst.setString(1,"C:/Documents and Settings/Administrator/Desktop/Leader.jpg");
    rs = pst.executeQuery();
    //System.out.println("status of result set is"+rs.next());
    System.out.println("finished writing the query");
    int i=1;
    if(rs.next())
    System.out.println("in rs") ;
    byte[] byte_image=rs.getBytes(1);
    // byte blob_byte[]= new byte[(byte)blob.length()];
    //System.out.println("length of byte is"+blob_byte);
    //String len1 = (Oracle.sql.blob)rs.getString(1);
    //System.out.println("value of string is"+len1);
    //int len = len1.length();
    //byte [] b = new byte[len];
    //in = rs.getBinaryStream(1);
    int index = in.read(byte_image, 0, byte_image.length);
    System.out.println("value of in and index are"+in+" "+index);
    FileOutputStream outImej = new FileOutputStream("C://"+i+".JPG");
    //FileOutputStream fos = new FileOutputStream (imgFileName);
    BufferedOutputStream bos = new BufferedOutputStream (outImej);
    //byte [] byte_array = new byte [blob_byte.length]; //assuming 512k size; you can vary
    //this size depending upon avlBytes
    //int bytes_read = in.read(blob_byte);
    bos.write(index);
    /*while (index != -1)
    outImej.write(blob_byte, 0, index);
    index = in.read(blob_byte, 0, blob_byte.length);
    //System.out.println("==========================");
    //System.out.println(index);
    //System.out.println(outImej);
    //System.out.println("==========================");
    /*ServletOutputStream sout = response.getOutputStream(outImej);
              for(int n = 0; n < blob_byte.length; n++) {
                   sout.write(blob_byte[n]);
              sout.flush();
              sout.close();*/
    outImej.close();
    //i++;
    else
    returnValue = 1;
    catch(Exception e)
    System.out.println("SQLEXCEPTION : " +e);
    finally {
    //out.close();
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    * Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    * Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    * Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    // </editor-fold>
    }

  • How to insert an image file as blob using JDBC Statement

    Hi,
    I'm new on java.
    I want the code to insert an image file in Oracle database whose data type is blob.
    i want to use JDBC statement not the prepared statement.
    Please help me out.

    user8739226 wrote:
    thanks for the solution.
    I want to ask one thing
    let say i've created a method in a bean in which i'm passing three parameters.
    One is tablename as String, Second is Name of tablefields as Object, Third is Values as Object
    Like:
    public synchronized int insert(String table,Object[] fields, Object[] values)Ah now we're getting somewhere. I was trying to come up with a situation where using a regular Statement over PreparedStatement would be viable and came up with practically nothing.
    In the method body i'm accessing the table fields and values and combining them into the insert sql query.
    how can i do this using preparedstatment.
    how do i come to know here in this bean that this value is int or string or date at runtime to use setInt, setString, setdate or setBlob respectively.That's your problem. Bad design. You want to make some sort of universal insert method that can insert anything anywhere. But it doesn't really make sense, because whenever you're trying to insert something, you know exactly what you want to insert and where. You could use a PreparedStatement at that point (although encapsulate it in its own method). Now you're trying to create your own poorly designed framework over JDBC that doesn't solve problems, only increases them.
    Above was the only reason i saw, i was using statement instead of preparedstatment as statement was looking easy in this situation.
    please, give me the solution of above using preparedstatment.No, rather you should reconsider your design. What advantage does your insert() method give you over, let's say using a regular PreparedStatement. Granted, you can put your connection opening and other boilerplate code in the method. But if that's your only problem, then your insert method isn't gonna be much use. You could always switch to JPA for example and work with that.

  • How I can store Image file in a database

    Can any one how i can stored image file in a database and then by using same database how i can show in HTML page...(in a browser)

    This is not something that can be answered easily. There is quite alot of code involved....
    To get started I suggest you read up on the built-in package 'DBMS_LOB' from Oracle . Most of what you need you should find there.
    regards Dave.

  • How to generate .SQL format file from oracle database?

    How to generate .SQL format file from oracle database?
    I have a database of Oracle 8.1.6,now want to generate script file (including table structure,index,etc.) from it,What should I do?
    Thanks.

    Your question pertains to the Database Export/Import. This forum exclusively focusses on the export/import utilities that come along with "Oracle Portal" which is a web-based tool. Could you please post your question under the RDBMS export/import or migration forum.

  • How to add an image file to Oracle db?

    Need help urgently....Anybody knows how to add an image file (example: jpg)into one of the fields in Oracle database??

    This will do the job..
    package forum;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    //import oracle.sql.*;
    Wanneer een request.getInputStream wordt geconferteerd naar een "String" (zie later) dan ziet de output in tekstformaat er als volgt uit:
    -----------------------------7d280152604f4 Content-Disposition: form-data; name="oploadfile"; filename="C:\WINNT\Profiles\mvo\Desktop\boodschap.txt" Content-Type: text/plain Deze boodschap dient te worden ge-insert in de database. -----------------------------7d280152604f4 Content-Disposition: form-data; name="StadID" 1234 -----------------------------7d280152604f4 Content-Disposition: form-data; name="SuccessPage" /forum/error.jsp -----------------------------7d280152604f4--
    of opgesplitst
    contentType........... multipart/form-data; boundary=---------------------------7d235ade00f0
    filename.............. "C:\Documents and Settings\Administrator\Desktop\boodschap.txt"
    MIME type............. text/plain
    Wat in database moet.. Dit is de eigenlijke boodschap die moet worden ge-insert in de database.
    Eind boundary......... -----------------------------7d235ade00f0 Content-Disposition: form-data; name="file1"; filename="" Content-Type: application/octet-stream -----------------------------7d235ade00f0--
    We gaan achtereenvolgens:
    1. Kijken of het van het "multipart/form-data" type is (uploaden) en strippen van eerste boundery.
    1.a Geen "multipart/form-data" ? dan... error message
    1.b Groter dan MAX_SIZE ?..dan .. error message
    2. Filenaam van de te uploaden file uitlezen
    3. Mimetype bepalen en bepalen in welke positie van de string het Mimetype ophoudt, cq waar te uploaden file begint
    4. Bepalen waar eind boundery begint
    5. De eigenlijke file uitlezen
    6. Terug converteren naar bytes
    public class WriteBlob extends HttpServlet {
    public static final int MAX_SIZE = ParameterSettings.imageUpload;
    String successMessage = "";
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    * Process the HTTP Get request
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    DataInputStream in = null;
    FileOutputStream fileOut= null;
    PrintWriter out = response.getWriter();
    int kb_size = 0;
    boolean pass2 = true;
    String message = "";
    String responseRedirect = "/forum/uploaden.jsp?message="+" Uploaden geslaagd";
    try
    //get content type of client request
    String contentType = request.getContentType();
    // Start stap 1...content type is multipart/form-data
    if(contentType != null && contentType.indexOf("multipart/form-data") != -1)
    //open input stream
    in = new DataInputStream(request.getInputStream());
    //get length of content data
    int formDataLength = request.getContentLength(); // totale lengte van de inputstream
    //initieer een byte array om content data op te slaan
    byte dataBytes[] = new byte[formDataLength];
    //read file into byte array
    int bytesRead = 0;
    int totalBytesRead = 0;
    int sizeCheck = 0;
    while (totalBytesRead < formDataLength)
    //kijken of de file niet te groot is
    sizeCheck = totalBytesRead + in.available();
    if (sizeCheck > MAX_SIZE)
    pass2 = false;
    message = "Sorry. U kunt slechts bestanden uploaden tot een grootte van 500KB";
    responseRedirect = "/forum/uploaden.jsp?message="+message;
    bytesRead = in.read(dataBytes, totalBytesRead,formDataLength);
    totalBytesRead += bytesRead;
    if (pass2==true)
    kb_size = (int)(formDataLength/1024);
    //create string from byte array for easy manipulation
    String file = new String(dataBytes);
    /*get boundary value (boundary is a unique string that separates content data)
    contentType........... multipart/form-data; boundary=---------------------------7d235ade00f0
    int lastIndex = contentType.lastIndexOf("=");
    String boundary = contentType.substring(lastIndex+1, contentType.length());
    // Stap 2.....bepaal de naam van de upload file
    // filename.............. "C:\Documents and Settings\Administrator\Desktop\boodschap.txt"
    String saveFile = file.substring(file.indexOf("filename=\"")+10);
    saveFile = saveFile.substring(0,saveFile.indexOf("\n"));
    saveFile = saveFile.substring(saveFile.lastIndexOf("\\")+1,saveFile.indexOf("\"")); //naam van de file...boodschap.txt
    String saveFileName = saveFile;
    // Stap 3..Bepaal MIME Type en de positie van eind mime type in string
    voorbeeld: -----------------------------7d23d21220524 Content-Disposition: form-data; name="file0"; filename="C:\WINNT\Profiles\mvo\Desktop\z clob.txt" Content-Type: text/plain
    String restant = "";
    int pos; //position in upload file
    // bijv .. filename="C:\Documents and Settings\Administrator\Desktop\boodschap.txt"
    pos = file.indexOf("filename=\"");
    //find position of content-disposition line
    pos = file.indexOf("\n",pos)+1; // eing file naam + spatie
    // onderstaand geeft bijv Content-Type: text/plain
    restant = file.substring(pos,file.indexOf("\n",pos)-1);
    restant = restant.substring(restant.indexOf(":")+2,restant.length()); // MIME type
    String mimeType = restant;
    //find position of eind content-type line
    pos = file.indexOf("\n",pos)+1;
    //find position of blank line
    pos = file.indexOf("\n",pos)+1;
    int start = pos;
    // Stap 4 eind boundary
    /*find the location of the next boundary marker (marking the end of the upload file data)*/
    int boundaryLocation = file.indexOf(boundary,pos)-4; //waarom -4 ..? ziet er uit als linebreak spatie--boundary=-----------------------------7d21c9ae00f0
    // Stap 5 en 6..de eigelijke te uploaden file in nieuwe byte file inserten
    byte dataBytes2[] = new byte[boundaryLocation-start]; //declareren
    for (int i=0;i<(boundaryLocation-start);i++) // inserten BELANGRIJK !!
    dataBytes2=dataBytes[start+i];
    String next_id = "0";
    Statement statement = null;
    Connection conn = null;
    boolean pass = true;
    ResultSet rs = null;
    Statement stmt_empty = null;
    oracle.sql.BLOB blb = null;
    try
    int vendor = DriverUtilities.ORACLE;
    String username = ConnectionParams.userName;
    String password = ConnectionParams.passWord;
    String connStr = DriverUtilities.makeURL(vendor);
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    conn = DriverManager.getConnection(connStr,username, password);
    if (conn==null){pass=false;}
    } catch (Exception e){out.println("<P>" + "There was an error establishing a connection:");}
    if (pass==true)
    try
    String seq_nextval ="select forum_blob_seq.nextval from dual";
    statement = conn.createStatement();
    ResultSet rset = statement.executeQuery(seq_nextval);
    while (rset.next())
    next_id = rset.getString(1);
    if (next_id.equals("0"))
    message = "Uploaden mislukt !...Er ging wat fout tijdens de interactie met de database";
    responseRedirect = "/forum/uploaden.jsp?message="+message;
    pass = false;
    } catch (Exception e1) { out.println("Error blob1 : "+e1.toString()); };
    } // end pass
    if (pass==true)
    try
    Statement stmt2 = conn.createStatement();
    String insert_empty_blob = "INSERT INTO test_blob(id "+
    ",filename "+
    ",mimetype "+
    ",kb) "+
    "VALUES("+Integer.parseInt(next_id) +
    ",'"+saveFileName+"'"+
    ",'"+mimeType+"'"+
    ","+kb_size+")";
    stmt2.executeQuery(insert_empty_blob);
    conn.commit();
    if (stmt2!= null) {stmt2.close();}else{stmt2.close();pass = false;}
    } catch (Exception e2){
    message = "Uploaden mislukt !...Er ging wat fout tijdens de interactie met de database";
    responseRedirect = "/forum/uploaden.jsp?message="+message;
    out.println("<P>" + "2. There was an error inserting mime type:");}
    } //end pass
    if (pass==true)
    try
    conn.setAutoCommit(false);
    } catch (Exception e3) { pass = false; out.println("Error blob 3: "+e3.toString()); };
    } //end pass
    if (pass==true)
    try
    String Query_blob ="Select test_blob FROM test_blob where id="+next_id+" FOR UPDATE";
    stmt_empty = conn.createStatement();
    rs=stmt_empty.executeQuery(Query_blob);
    } catch (Exception e4) {
    pass = false;
    out.println("Error blob 4: "+e4.toString());
    message = "Uploaden mislukt !...Er ging wat fout tijdens de interactie met de database";
    responseRedirect = "/forum/uploaden.jsp?message="+message;};
    } //end pass
    if (pass==true)
    try
                             if (rs.next())
                             blb = ((OracleResultSet)rs).getBLOB(1);
                        OutputStream stmBlobStream = blb.getBinaryOutputStream();
                             try {
                                  int iSize = blb.getBufferSize();
                             byte[] byBuffer = new byte[iSize];
                             int iLength = -1;
    ByteArrayInputStream stmByteIn = new ByteArrayInputStream(dataBytes2);
                                  try {
    // while ( (iLength = in.read(byBuffer, 0,      iSize)) != -1 )
    while ( (iLength = stmByteIn.read(byBuffer, 0,      iSize)) != -1 )
                                       stmBlobStream.write(byBuffer, 0, iLength);
                                       stmBlobStream.flush();
                                       } // end while
    } catch (Exception e5) {
    pass=false;
    out.println("Error blob 5: "+e5.toString());
    message = "Uploaden mislukt !...Er ging wat fout tijdens de interactie met de database";
    responseRedirect = "/forum/uploaden.jsp?message="+message; }
                                  finally { conn.commit();     }
    } catch (Exception e6) { out.println("Error blob 6: "+e6.toString()); };
                             } //end if rs.next()
                             else {      throw new SQLException("Could not locate message record in database."); }
    } catch (Exception e7) { out.println("Error blob : "+e7.toString()); };
    } // end pass
    } // end pass2
    else //request is not multipart/form-data
    message = "Uploaden mislukt !...Gegevens niet verstuurd via multipart/form-data.";
    responseRedirect = "/forum/error.jsp?message="+message;
    out.println("Request not multipart/form-data.");
    catch(Exception e)
    try
    //print error message to standard out
    out.println("Error in doPost: " + e);
    //send error message to client
    out.println("An unexpected error has occurred.");
    out.println("Error description: " + e);
    }catch (Exception f) {}
    response.sendRedirect(responseRedirect);
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    doPost(request,response);
    Regards
    Martin

  • How to export an XML file from oracle database?

    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
    thanks in advance,
    Bala.
    Edited by: user3523292 on Nov 14, 2008 5:43 AM

    user3523292 wrote:
    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
    thanks in advance,
    Bala.
    Edited by: user3523292 on Nov 14, 2008 5:43 AMThis is a forum of volunteers. There is no "urgent" here. Nevertheless, a google search of 'xml oracle export' quickly lead me to this Oracle site:
    otn.oracle.com/sample_code/tech/xml/index.html
    I also see lots of hits when I search the documentation library at tahiti.oracle.com for 'xml'. This one in particular may be what you are looking for:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14252/adx_j_xsu.htm#ADXDK070

  • How to insert folloiwng XML file in Oracle -

    Hello
    This is on Database 11g.
    I have a very large XML file with following elements. I am new to PL SQL XML programming. How can I make Oracle read the OS file location where the XML file is located, open the XML file and insert XML data residing in their tag elements and non-tag elements ?
    <BillOfMaterialItem revisionIdentifier="--" billOfMaterialItemIdentifier="645-173-1" billOfMaterialItemUniqueIdentifier="IVI123019387" itemQuantity="6" globalProductQuantityTypeCode="PerAssembly" globalProductQuantityTypeCodeOther="" notes="" description="3/8" WIDE" proprietarySequenceIdentifier="115510509">
    - <AdditionalAttributes groupLabel="BOM Information">
      <AdditionalAttribute name="Line Number" value="20" dataType="Float" />
      </AdditionalAttributes>
      </BillOfMaterialItem>
    {code}
    Thanks,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    forum has many example
    look at Re: Load xml data in Oracle table
    steps:
    - create oracle directory
    - create table(s) for your data, may be with column xmltype
    - parse xml files from oracle directory and insert into table(s)
    for example
    SQL> select * from v$version where rownum=1;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    SQL>
    SQL> select *
      2      from (xmltable('*'
      3                     passing (xmltype(bfilename('GET_XML','sample.xml'),nls_charset_id('AL32UTF8')))
      4                     columns billofmaterialitem_revisionid varchar2(10) path '/BillOfMaterialItem/@revisionIdentifier'
      5                            , billofmaterialitem_itemid varchar2(20) path '/BillOfMaterialItem/@billOfMaterialItemIdentifier'
      6                            , BillOfMaterialItem_ItUId varchar2(20) PATH '/BillOfMaterialItem/@billOfMaterialItemUniqueIdentifier'
      7                            , billofmaterialitem_itemq varchar2(20) path '/BillOfMaterialItem/@itemQuantity'
      8                            , billofmaterialitem_gqtcode varchar2(20) path '/BillOfMaterialItem/@globalProductQuantityTypeCode'
      9                            , BillOfMaterialItem_notes varchar2(20) PATH '/BillOfMaterialItem/@notes'
    10                            , BillOfMaterialItem_desc varchar2(20) PATH '/BillOfMaterialItem/@description'
    11                            , billofmaterialitem_prseqid varchar2(20) path '/BillOfMaterialItem/@proprietarySequenceIdentifier'
    12                            , additionalattributes_grlbl varchar2(20) path '/BillOfMaterialItem/AdditionalAttributes/@groupLabel'
    13                            , additionalattribute_name varchar2(20) path '/BillOfMaterialItem/AdditionalAttributes//AdditionalAttribute/@name'
    14                            , additionalattribute_value varchar2(20) path '/BillOfMaterialItem/AdditionalAttributes//AdditionalAttribute/@value'
    15                            , AdditionalAttribute_dataType varchar2(20) PATH '/BillOfMaterialItem/AdditionalAttributes//AdditionalAttribute/@dataType'
    16                    )
    17           ) x
    18  /
    BILLOFMATERIALITEM_REVISIONID BILLOFMATERIALITEM_ITEMID BILLOFMATERIALITEM_ITUID BILLOFMATERIALITEM_ITEMQ BILLOFMATERIALITEM_GQTCODE BILLOFMATERIALITEM_NOTES BILLOFMATERIALITEM_DESC BILLOFMATERIALITEM_PRSEQID ADDITIONALATTRIBUTES_GRLBL ADDITIONALATTRIBUTE_NAME ADDITIONALATTRIBUTE_VALUE ADDITIONALATTRIBUTE_DATATYPE
    --                            645-173-1                 IVI123019387             6                        PerAssembly                                         3/8                     115510509                  BOM Information            Line Number              20                        Float
    SQL>

  • How to insert a image file in oracle8i db

    hi..
    i want to add some new logo's in my oracle 8i database...i created the column and datatype for that but i don't know the proper command for
    insert the logo.
    so i need u r help..and i want to use that logo in my reports6i too.
    regards
    kannan

    Hi,
    Check this
    Insert Picture (image) using oracle forms
    HTH
    - Pavan Kumar N

  • How to load excel-csv file into oracle database

    Hi
    I wanted to load excel file with csv extension(named as trial.csv) into
    oracle database table(named as dept),I have given below my experiment here.
    I am getting the following error,how should I rectify this?
    For ID column I have defined as number(5) datatype, in my control file I have defined as interger external(5),where as in the Error log file why the datatype for ID column is comming as character?
    1)my oracle database table is
    SQL> desc dept;
    Name Null? Type
    ID NUMBER(5)
    DNAME CHAR(20)
    2)my data file is(trial.csv)
    ID     DNAME
    11     production
    22     purchase
    33     inspection
    3)my control file is(trial.ctl)
    LOAD DATA
    INFILE 'trial.csv'
    BADFILE 'trial.bad'
    DISCARDFILE 'trial.dsc'
    APPEND
    INTO TABLE dept
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    (ID POSITION(1:5) INTEGER EXTERNAL(5)      
    NULLIF ID=BLANKS,
    DNAME POSITION(6:25) CHAR
         NULLIF DNAME=BLANKS
    3)my syntax on cmd prompt is
    c:\>sqlldr scott/tiger@xxx control=trial.ctl direct=true;
    Load completed - logical record count 21.
    4)my log file error message is
    Column Name Position Len Term Encl Datatype
    ID           1:5 5 , O(") CHARACTER
    NULL if ID = BLANKS
    DNAME 6:25 20 , O(") CHARACTER
    NULL if DNAME = BLANKS
    Record 1: Rejected - Error on table DEPT, column ID.
    ORA-01722: invalid number
    Record 21: Rejected - Error on table DEPT, column ID.
    ORA-01722: invalid number
    Table DEPT:
    0 Rows successfully loaded.
    21 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Bind array size not used in direct path.
    Column array rows : 5000
    Stream buffer bytes: 256000
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records read: 21
    Total logical records rejected: 21
    Total logical records discarded: 0
    Total stream buffers loaded by SQL*Loader main thread: 0
    Total stream buffers loaded by SQL*Loader load thread: 0
    5)Result
    SQL> select * from dept;
    no rows selected
    by
    balamuralikrishnan.s

    Hi everyone!
    The following are the steps to load a excell sheet to oracle table.i tried to be as simple as possible.
    thanks
    Step # 1
    Prapare a data file (excel sheet) that would be uploaded to oracle table.
    "Save As" a excel sheet to ".csv" (comma seperated values) format.
    Then save as to " .dat " file.
    e.g datafile.bat
    1,Category Wise Consumption Summary,Expected Receipts Report
    2,Category Wise Receipts Summary,Forecast Detail Report
    3,Current Stock List Category Wise,Forecast rule listing
    4,Daily Production Report,Freight carrier listing
    5,Daily Transactions Report,Inventory Value Report
    Step # 2
    Prapare a control file that define the data file to be loaded ,columns seperation value,name and type of the table columns to which data is to be loaded.The control file extension should be " .ctl " !
    e.g i want to load the data into tasks table ,from the datafile.dat file and having controlfile.ctl control file.
    SQL> desc tasks;
    Name Null? Type
    TASK_ID NOT NULL NUMBER(14)
    TASK_NAME VARCHAR2(120)
    TASK_CODE VARCHAR2(120)
    : controlfile.ctl
    LOAD DATA
    INFILE 'e:\datafile.dat'
    INTO TABLE tasks
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    (TASK_ID INTEGER EXTERNAL,
    TASK_NAME CHAR,
    TASK_CODE CHAR)
    The above is the structure for a control file.
    Step # 3
    the final step is to give the sqlldr command to execute the process.
    sqlldr userid=scott/tiger@abc control=e:\controlfile.ctl log=e:\logfile.log
    Message was edited by:
    user578762

  • How to access a PDF file from Oracle DATABASE SERVER

    Hi
    I have some pdf files in "\home2\docs" directory in Oracle database server 10g. (OS is Linux) I want to access those pdf files from my client system through Oracle Forms. How is it possible?
    Please Help!!!! It is very urgent !!!
    Expecting fast response!!!!!
    Bye

    hi
    Thank u for ur response.
    Initially i tried to access pdf file from database server. I didn't get any solution for that. So I copied all my pdf files to Application server which is in Linux environment at "/home2/docs" directory.
    I gave the following command for accessing the pdf files kept in Lnux Application Server from Oracle 10g forms in a button press trigger.
    web.show_document('http://192.168.1.53:7779/home2/docs/test.pdf');
    It says "page cannot be found"
    So I copied one of the pdf file named "test.pdf" to "/oracle/oas10g/IasHome/forms90/java" in Linux Application Server . Then the following command
    web.show_document('http://192.168.1.53:7779/forms90/java/test.pdf');
    has opened the the pdf file in browser.
    192.168.1.53 is my Linux Application Server IP. and 7779 is the port.
    Actually we have lacs of pdf files. So i cannot keep all the pdf files in "/oracle/oas10g/IasHome/forms90/java" directory in Linux Application Server. And also all the pdf files not in the same directory , "/home2/docs" some of the pdf files r in the subdirectories of "/home2/docs/" like /home2/docs/sub1, /home2/docs/sub2, /home2/docs/sub3 etc.
    Then how to configure my "/oracle/oas10g/IasHome/forms90/server/forms90.conf" file for retrieving pdf files from "/home2/docs/" and its subdirectories. Is Anything other than this, required for solving my problems.
    Now My PDF files r in LINUX APPLICATION SERVER not in database server.
    Please help!! It is VERY URGENT!!!

  • How to insert data type information to 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!!

    I don't have time to read thru all your code, but I hope this information will help you.
    It depends on how the Oracle database was set up. Usually, the date format is something like this: '27-MAY-2003 22:10:00'. A quick check will be to run this SQL script in SQLPlus:
    select sysdate from dual;
    You have to convert the date from textbox or whatever to this exact Oracle format. Otherwise, Oracle will not accept it. It is very picky on that. I found the best way is to do the conversion inside the SQL statement. It makes life so much easier.
    Hope this helps.

  • How to insert multi language data to oracle database

    Hi ,
    Can any one suggest the steps involved in implementing storage/retrieval of data in the language otherthan english on the database?. I am using Oracle 9i database.
    I want to write sql scripts to insert data to the database.How can i insert the data in the language otherthan english i.e hindi. ensuring storage and display of data is fine at the backend.
    CHARACTERSET is set AL32UTF8 and need to insert the data in the NVARCHAR2 datatype enabled column.
    Any suggestions would be greatly appreciated.
    Thanks and Regards,
    Poornima

    If you can write the text in Notepad, then enter the text and save the file with the encoding "Unicode big endian". Then, open the file in a hex editor. The first two bytes will be 0xFE and 0xFF (this is the Byte Order Mark). This code should be skipped for database storage as it is relevant to flat files only. What follows are two-byte character codes that you can put into UNISTR calls. The file with the word "Patra" will show up in the hex editor as:
    FE FF 09 2a 09 24 09 4d 09 30
    If you can enter the characters in your HTML browser, you can use the very useful conversion page at http://rishida.net/tools/conversion/ (this is not an official endorsement from Oracle but my personal advice). Enter the characters into the "Characters" text area and click on the corresponding [Convert] button. The "Hexadecimal code points" field will tell you the codes that you need to prefix with backslash and put into the UNISTR call.
    If you are unable to enter the characters on your workstation, then you can identify each letter in the text and look it up in the Unicode character database at http://www.unicode.org/Public/UNIDATA/Index.txt or http://www.unicode.org/Public/UNIDATA/NamesList.txt. The four-digit hexadecimal codes listed there are what you are looking for. Unfortunately, such lookup will not work for Chinese Han and Japanese Kanji characters as they have no names in Unicode.
    Another method is to use files in another language-specific encoding and convert them to Unicode before loading them into the AL32UTF8 database.
    -- Sergiusz

  • How to display BLOB images from the Oracle database within Crystal

    Let's say a have the following table
    IMAGES
    ========
    DOC_ID NUMBER
    DOC_NAME STRING
    DOC_IMAGE BLOB
    The BLOB field can have any type of document: PDF, email, WORD, EXcel, etc. I would like to present the DOC_ID and DOC_NAME and let the user click any of them. Once the user clicks the document stored in the database as BLOB, it is rendered using the default application associated to the extension. For example if the file name is ABC.XLS open MSExcel if the file is abc.pdf open Acrobat.
    I am using Crystal2008 and evaluating Crystal 4.0
    Does this requires programming?
    Thanks!!!

    Hi
    Crystal is a reporting tool and you canu2019t execute any code except free hand SQL.  When you pull any BLOB fields in crystal, it takes as a picture field and if that field contains image only it will display in your report.
    If you have any information other than image, it will not display any info in the report.
    If you want to insert Word , PDF and Excel then you will have to insert as ole object and can manage with location of the files.
    Thanks,
    Sastry

Maybe you are looking for

  • Nokia 770: Can't Surf The Net In Hotels

    When trying to connect my Nokia 770 Internet Tablet while in hotels, I find that my success is hit and miss. But I can use a laptop and connect. The difference is the browser on the laptop defaults to a web page from the ISP where I have to agree to

  • Routing for configurable material

    Hello PP gurs, I want to create Routing for Configurable Material in SAP PP-PI or PP industries. How the object dependency is defined applied ? This requirement is for Make TO Order scenario for Configurable Material. At present I am working with res

  • Disk Utility short-changed me by 20GB

    I partitioned my new Time Machine external drive exactly as per the log below. Upon inspection of the drive afterwards, partition 1 is indeed 455GB but partition 2 is only 10GB instead of the 30GB requested (and delivered according to the log). Anyon

  • Distnct Keyword

    Hi Everyone, I've a select query having a distinct keyword to reduce the duplicates. Later I found that my query is taking a little bit more time to execute because of this distinct keyword. So I wrote my query some thing like this as mentioned below

  • Information Broadcasting issue

    Hi, I have a BW query which is automated to run in background through Information Broadcasting to send the report to couple of users. The query 'A' runs for 3 hours in Production , it used to run fine. There were no changes done to the Broadcaster se