Import a blob from Olite to Oracle

Hi,
I'm trying to make a java program who will import an Olite database to our Oracle Server. Everything works except for BLOB datatype.
I'm not able to get the blob columns from olite and then insert it into Oracle server.
I have examples where we insert a blob in the database from a File but I'm not able to get it work when the source is Olite and the destination is oracle.
Is anyone can give me an example.
Thank you.

Importing BLOB objects into the main oracle database is a bit odd as you cannot do a direct insert, you need to load it using an update statement.
The below is the import procedure we use to load a blob column from a server file. There is some extraneous bits in there, but basically and insert with an EMPTY_BLOB, and then an update statement to load from the read in file. If the data record is already there, you can skip the insert statement, but just do the update
PROCEDURE pr_load_file
System          :     FUSION
Module Name     :     pr_load_file
Description     :     Main call. Create a new pda_applications record, and impost the specified fiel into it
Copyright(c)     :     NHBC 2004
Version History:
Vers. Author Date Reason
1.0 G Wilkinson 03/02/2006 Initial Version.
(PA_VERSION IN NUMBER
,PA_FILENAME IN VARCHAR2
,PA_PDAAT_CODE IN VARCHAR2
,PA_PART_NO IN NUMBER DEFAULT 1
,PA_DEPLOY IN VARCHAR2 DEFAULT 'Y')
IS
l_FileLocator BFILE;
l_blobLocator BLOB;
l_seq NUMBER;
l_location VARCHAR2(20);
no_params EXCEPTION;
call_fail EXCEPTION;
BEGIN
-- Throw error if required details not present
IF pa_version IS NULL
OR pa_filename IS NULL
OR pa_pdaat_code IS NULL THEN
RAISE no_params;
END IF;
-- Initialize the character locator for writing. Note that we have
-- to select a blob from a table FOR UPDATE. This locks the row,
-- and is a requirement for LOADFROMFILE.
SELECT pdaa_id_seq.nextval
INTO l_seq
FROM dual;
-- First create the application record (file is imported by update, not insert
INSERT INTO pda_applications
(ID,PDAAT_CODE,VERSION,PART_NO,FILE_OBJECT,DEPLOY_APPLICATION_YN)
VALUES (l_seq,pa_pdaat_code,pa_version,pa_part_no,EMPTY_BLOB(),pa_deploy);
-- Lock record for update to import the file
SELECT file_object INTO l_blobLocator
FROM pda_applications
WHERE id=l_seq
FOR UPDATE;
-- Initialize the BFILE locator for reading.
l_FileLocator := BFILENAME('CDP_FILE_UPLOAD', pa_filename);
DBMS_LOB.FILEOPEN(l_FileLocator, DBMS_LOB.FILE_READONLY);
-- Load the entire file into the character LOB.
-- This is necessary so that we have the data in
-- character rather than RAW variables.
DBMS_LOB.LOADFROMFILE(l_blobLocator, l_FileLocator
,DBMS_LOB.GETLENGTH(l_FileLocator)
,src_offset => 1);
-- Clean up.
DBMS_LOB.FILECLOSE(l_FileLocator);
-- Create download records for each user associated with the application for sending to the PDA's
-- to install the software
IF pa_deploy = 'Y' then
IF fn_deploy (pa_pdaa_id => l_seq
,pa_pdaat_code => pa_pdaat_code) != 'SUCCESS' THEN
RAISE call_fail;
END IF;
END IF;
EXCEPTION
WHEN no_params THEN
pkg_appm.pr_log_message( pa_mdl_name => g_module_name
, pa_mdl_version => fn_get_body_version
, pa_error_code => SQLCODE
, pa_location => l_location
, pa_text => 'Missing parameters'
, pa_severity => 'E'
WHEN OTHERS THEN
DBMS_LOB.FILECLOSE(l_FileLocator);
pkg_appm.pr_log_message( pa_mdl_name => g_module_name
, pa_mdl_version => fn_get_body_version
, pa_error_code => SQLCODE
, pa_location => l_location
, pa_text => SQLERRM
, pa_severity => 'E'
END pr_load_file;
--

Similar Messages

  • Importing DB info from Sybase to Oracle 9i

    Could someone please tell me if it is possible to import a sybase db into oracle 9i. The reason, I need to be able to import and excisting DB from sybase to Oracle for a project.

    In your control file for SQL*Loader, specify the timestamp with format like "Mon DD yyy hh:mi:ss:ff3AM".

  • Importing Expense Report from legacy to Oracle Payables??

    All,
    I need to import ER from legacy to payables. I used ap_expense_reports_headers_all & ap_expense_report_lines_all tables. But the "Expense Report Program" is not picking up the data from the tables though i populated all the required columns of the tables!!! When i open the "View Output" it says "The conc.request did not create an output file"!!!
    Can anyone tell me what could be the reason behind the failure of the program?
    Do I need to populate anyother column to resolve this issue?
    Detailed response is highly appreciated.
    thanks in advance,
    Sen

    Steps to import into AP
    Navigate to the Accounts Payable Responsibility
    Go to View -> Requests -> Submit a New Request -> Single Request -> OK
    Submit the Expense Report Export Program, after specifying all the mandatory parameters
    Source parameter should 'Oracle Internet Expenses'
    To view the expense report created
    Navigate to the Accounts Payable Responsibility attached to the User
    Go to Invoices -> Entry -> Invoices
    In the Invoice Workbench Window query the Invoice Num field with the Name of the Expense Report created in the previous step. The Invoice is displayed in the Invoice Workbench with the Type as Expense Report

  • Import/insert data from XML into Oracle database tables?

    Hi. (I am using JDeveloper 10.1.3.3.0 and Oracle 10g)
    I have been able to export the data from one of my database tables by using a View Object and .writeXML.
    Now, I want to take an xml file that is formatted in the same way as what is spit out by the writeXML and put that info in my database table. I followed online examples and have tried using .readXML like so:
    Element element = XMLDoc.getDocumentElement();
    vo.readXML(element, -1);
    I know it is sort of working, because at first I got an error message that one of the required attributes was missing. So, I added that attribute to my xml file and ran my code. No errors. But, I checked my database, and the new records were not added.
    Is there something I have done wrong? Or is there perhaps something I left out? I also noticed there were several versions of readXML like readFromXML. Which one should I use and how?
    Thanks.

    KUBA, I changed my code to match your example:
    DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    File xmlFile = new File("C:/myfilehere.xml");
    Document doc = db.parse(xmlFile);
    Element element = doc.getDocumentElement();
    vo.readXML(element, -1);
    vo.getDBTransaction().commit();
    I still get no errors, but my database table has no new records.
    Any ideas why?
    Thanks.

  • How to import a table from another oracle database ?

    Hi all ,
    i could like to use pl/sql to import one table from another oracle database server ?
    is it possible to do this ?
    A server B server
    table: test <------------------------> table : newtest
    the tns profile already configurated . the connection is ready .
    thanks a lot !
    Best Regards,
    Carlos

    if i don't have TEST table on server B whether COPY command will create this table on server B with the same structure ? If you specify CREATE as a clause the table will be created:
    SQL> help copy
    COPY
    COPY copies data from a query to a table in a local or remote
    database. COPY supports CHAR, DATE, LONG, NUMBER and VARCHAR2.
    COPY {FROM database | TO database | FROM database TO database}
                APPENDCREATE|INSERT|REPLACE} destination_table
                [(column, column, column, ...)] USING query
    where database has the following syntax:
         username[password]@connect_identifier

  • Import some data from one oracle to another...

    Hi Guys,
    we have 2 oracle database servers on 2 different machines with schema.
    I want to import some data from a specific table from one oracle into another oracle.
    what is the way to do that.
    Please help in details
    Imran Baig

    Hi,
    Thanks for the reply.
    Tables are already created in both of the oralce databases only the data varies. I just have to import only few records from one oracle to another with the same user name and table already existing.
    I have tried using database link. I can view records from the other oracle database but as soon as i write an insert command oracle gets held. I cant do anything.
    Is there any other way?
    Imran

  • Best way to import data to multiple tables in oracle d.b from sql server

    HI All am newbie to Oracle,
    What is the Best way to import data to multiple tables in Oracle Data base from sql server?
    1)linked server?
    2)ssis ?
    If possible share me the query to done this task using Linked server?
    Regards,
    KoteRavindra.

    check:
    http://www.mssqltips.com/sqlservertip/2011/export-sql-server-data-to-oracle-using-ssis/
          koteravindra     
    Handle:      koteravindra 
    Status Level:      Newbie
    Registered:      Jan 9, 2013
    Total Posts:      4
    Total Questions:      3 (3 unresolved)
    why so many unresolved questions? Remember to close your threads marking them as answered.

  • Reading BLOB from SQL Server 2005 using DB Link from Oracle 10g

    Hi All,
    I am trying to read a table's data from SQL Server 2005 using ODBC DB Link created in Oracle 10g (10.2.0.3/4) database. I am not using oracle gateway.
    I am able read all data except for the BLOB data from SQL server 2005. It gives error given below when I try to execute query SELECT * from T_TRANSACTION_DATA@sdeslink inside a stored procedure:
    ORA-22992: cannot use LOB locators selected from remote tables
    Kindly help how to read BLOB from SQL server 2005 inside Oracle 10g.
    Best Regards!
    Irfan

    Irfan,
    If you can read the blob data using 10.2 HSODBC then there should be no problem using the 11g gateway.
    I recommend you download the latest version which is 11.2.0.3 available from My oracle Support as -
    Patch 10404530: 11.2.0.3.0 PATCH SET FOR ORACLE DATABASE SERVER
    This is a full version and does not need a previous version to have bene installed. When installing it needs to be in a completlely separate ORACLE_HOME from the existing 11.2 install.
    For the Ora-22992 problem have a look at this note in My Oracle Support -
    Ora-22992 has a workaround in 10gR2 (Doc ID 436707.1)
    Regards,
    Mike

  • Importing the data from MS SQL Server 7.0 SP3 to ORACLE 8i - 8.1.7

    How can I import a database from SQL Server to ORACLE Databas
    server ?
    It would be great if you could help me with that ...
    Thanks,
    Murad

    Hi,
    This error is fixed in the production verison of the SQL Server 7.0 plugin. This will be released in the next few weeks with the Oracle 8i relase 2 for Windows NT.
    Regards
    John

  • Import from Excel to Oracle table

    I have couple questions.
    is the 20K Excel file upload limit still apply???
    I want to use APEX to upload data from Excel to Oracle, some data manipulation will be needed in the process.
    This will be a utility that will be used by users not DBAs or Developers.
    It would great if someone has an example application.
    or do you think I should use different tool???
    Thanks

    What are the steps for importing using the SQL
    developer?Steps are (assuming you have already installed XE und schema where data should be imported):
    1. Install SQL Developer
    2. Start SQL Developer
    3. Log on into desired schema
    4. Open Dialog Box "Excel Import Data"
    5. Specify file to import with options
    6. Click on OK
    7. Check in Navigator imported data's
    Done ;-)

  • Retrieving BLOB from Oracle 8.1.7

    I am having problems trying to extract a BLOB from and oracle dbase
    I keep getting the same ERROR:
    java.sql.SQLException: ORA-00942: table or view does not exist
    ORA-06512: at "SYS.DBMS_LOB", line 492
    ORA-06512: at line 1
    The exception gets thrown on the folloiwng line
    InputStream blobStream = blob.getBinaryStream();Here's my code. Any ideas would be most useful
    public class testBlob
      public static void main(String args[])
        DatabaseRegistry dbaseRegistry = DatabaseRegistry.getInstance();
        Database ebbosDbase = dbaseRegistry.getDatabase("Test");
        Connection conn = null;
        try
          conn = ebbosDbase.getConnection();
          DatabaseMetaData dmeta = conn.getMetaData();
          OracleCallableStatement oracleStatement = (OracleCallableStatement)conn.prepareCall("begin email_dispatch_pkg.extract_email_templates( ? ); end;");
          oracleStatement.registerOutParameter(1, OracleTypes.CURSOR);
          oracleStatement.execute();
          ResultSet rst = oracleStatement.getCursor(1);
          ResultSetMetaData meta = rst.getMetaData();
          int columns = meta.getColumnCount();
          while(rst.next())
            for(int i=1; i <= columns ; i++)
              System.out.println("COLUMN NAME=" + meta.getColumnClassName(i));
              System.out.println("COLUMN TYPE=" + meta.getColumnTypeName(i));
            BLOB blob = ((OracleResultSet)rst).getBLOB(7);
            InputStream blobStream = blob.getBinaryStream();
            System.out.println("blob length : " + blob.length());
            FileOutputStream fileOutStream = new FileOutputStream("/home/mt04803/test.pdf");
            byte[] buffer = new byte[10];
            int nbytes = 0;
            while ((nbytes = blobStream.read(buffer))!= -1)
              fileOutStream.write(buffer,0,nbytes);
            fileOutStream.flush();
            fileOutStream.close();
            blobStream.close();
        catch(Exception e)
          e.printStackTrace();
        finally
          try
            ebbosDbase.close(conn);
          catch(Exception e)
            e.printStackTrace();
        System.exit(0);
    }

    I think the ORACLE Error says that the Table or View does not exists. So it is just that the table or procedure which u are executing is not visible to the User you are logging in as.

  • Any method to Import the data from Ingres Database to Oracle Database

    Hi,
    Is there any method to import the datas from Ingres Database to Oracle Database,
    Thanks in Advance.

    Check out this link.
    HTH...

  • Plesae help- needing to read a blob from db into bytes[]

    Hi all,
    I am having a requirement to read a blob stored in the oracle table and convert it into bytes. I am loading this table (wwv_flow_files) with APEX.
    The code under page 1 is as follows:
    DECLARE
    z number;
    y varchar2(4000);
    x varchar2(400);
    b blob;
    BEGIN
    select filename,blob_content into x ,b from APEX_APPLICATION_files where name =:P1_FILE_NAME;
    select length(convertBlobToBytes(b)) into z from dual;
    :P1_RESULT := z;
    end;
    Java code is as follows:
    import java.io.*;
    import java.sql.Blob;
    public class convertBlob {
    * @param blob
    * @return
    public static byte[] convertBlobToBytes(Blob blob) {
         if (blob==null) return null;
         try {
         InputStream in = blob.getBinaryStream();
         int len = (int) blob.length(); //read as long     
    long pos = 1; //indexing starts from 1
         byte[] bytes = blob.getBytes(pos, len);           
    in.close();
         return bytes;     
    catch (Exception e) {
         System.out.println(e.getMessage());
         return null;
    PL/SQL wrapper is as follows:
    CREATE OR REPLACE FUNCTION convertBlobToBytes(p1 IN BLOB) RETURN LONG RAW AUTHID CURRENT_USER AS LANGUAGE JAVA NAME 'convertBlob.convertBlobToBytes(java.sql.Blob) return byte[]';
    I loaded this java class and pl/sql wrapper into the database using JDEVELOPER.
    But I am getting the length of the file, as twice the size.
    For example, When I run the program which reads the file returns the length of the file as a byte array, the length is 819.
    When I pass the same file as a blob from apex, to the java program that converts blob to bytes, the length of the file is 1638.
    And hence I am getting wrong results, further in the process.
    Can you please help me? Any help is appreciated.
    rgds,
    Suma.

    Hi all,
    Can any of you please help me out?
    rgds,
    Suma.

  • Is it possible to pass blob from java to PL/SQL ?

    Hi, I try to bind a PL/SQL function who return a blob to a java class :
    Signature of java method :
        public static Blob getBLOB(int aId, String aJDBC) {Create PL/SQL function :
    create or replace function aa_java(myPiId in number,myPiJDBC in varchar2) return blob
    as language java
    name 'zip.ReadBLOB.getBLOB(int,java.lang.String) return java.sql.Blob';
    /In java code, my blob has the right size (150 Ko) but in PL/SQL, size = 0 !!!
    Any ideas ?

A: Is it possible to pass blob from java to PL/SQL ?

Thank you, but I think I have a Java problem...
Here is my code :
package zip;
import java.sql.*;
import oracle.jdbc.OracleDriver;
import oracle.sql.BLOB;
public class ReadBLOB {
    public static BLOB getBLOB(int aId, String aJDBC) {
        BLOB vBlob = null;
        try {
            DriverManager.registerDriver(new OracleDriver());
            Connection connection = DriverManager.getConnection(
                aJDBC,
            PreparedStatement stat = connection
                .prepareStatement("select image from aa_blob where id="+aId);
            ResultSet rs = stat.executeQuery();
            if (rs.next()) {
                vBlob = (BLOB) rs.getBlob(1);
                System.out.println("Taille 1 : "+vBlob.length());
            connection.close();
        } catch (Exception e) {
            e.printStackTrace();
        return vBlob;
    public static void main(String[] args) throws Exception {
        BLOB vBlob = getBLOB(1, "jdbc:oracle:thin:@vdn-ceg5:1521:DEV5");
        System.out.println("Taille 2 : "+vBlob.getLength());
}When I run the main method, I have :
Taille 1 : 150260
Taille 2 : 86
!!!!????!!!!????

Thank you, but I think I have a Java problem...
Here is my code :
package zip;
import java.sql.*;
import oracle.jdbc.OracleDriver;
import oracle.sql.BLOB;
public class ReadBLOB {
    public static BLOB getBLOB(int aId, String aJDBC) {
        BLOB vBlob = null;
        try {
            DriverManager.registerDriver(new OracleDriver());
            Connection connection = DriverManager.getConnection(
                aJDBC,
            PreparedStatement stat = connection
                .prepareStatement("select image from aa_blob where id="+aId);
            ResultSet rs = stat.executeQuery();
            if (rs.next()) {
                vBlob = (BLOB) rs.getBlob(1);
                System.out.println("Taille 1 : "+vBlob.length());
            connection.close();
        } catch (Exception e) {
            e.printStackTrace();
        return vBlob;
    public static void main(String[] args) throws Exception {
        BLOB vBlob = getBLOB(1, "jdbc:oracle:thin:@vdn-ceg5:1521:DEV5");
        System.out.println("Taille 2 : "+vBlob.getLength());
}When I run the main method, I have :
Taille 1 : 150260
Taille 2 : 86
!!!!????!!!!????

  • Data From Excel to Oracle

    Hi, how can I do a Stored Procedure or free code to import data from Excel to Oracle Table? Tanks for all.

    I never use UTL_FILE. I use Delphi and I need to make a subrotine to import xls file to oracle. So, I prefer to do into DataBase, using database resource, but I do not oracle expertise, I have some difficulties. Tanks.

  • Maybe you are looking for