Bulk loading BLOBs using PL/SQL - is it possible?

Hi -
Does anyone have a good reference article or example of how I can bulk load BLOBs (videos, images, audio, office docs/pdf) into the database using PL/SQL?
Every example I've ever seen in PL/SQL for loading BLOBs does a commit; after each file loaded ... which doesn't seem very scalable.
Can we pass in an array of BLOBs from the application, into PL/SQL and loop through that array and then issue a commit after the loop terminates?
Any advice or help is appreciated. Thanks
LJ

It is easy enough to modify the example to commit every N files. If you are loading large amounts of media, I think that you will find that the time to load the media is far greater than the time spent in SQL statements doing inserts or retrieves. Thus, I would not expect to see any significant benefit to changing the example to use PL/SQL collection types in order to do bulk row operations.
If your goal is high performance bulk load of binary content then I would suggest that you look to use Sqlldr. A PL/SQL program loading from BFILEs is limited to loading files that are accessible from the database server file system. Sqlldr can do this but it can also load data from a remote client. Sqlldr has parameters to control batching of operations.
See section 7.3 of the Oracle Multimedia DICOM Developer's Guide for the example Loading DICOM Content Using the SQL*Loader Utility. You will need to adapt this example to the other Multimedia objects (ORDImage, ORDAudio .. etc) but the basic concepts are the same.
Once the binary content is loaded into the database, you will need a to write a program to loop over the new content and initialize the Multimedia objects (extract attributes). The example in 7.3 contains a sample program that does this for the ORDDicom object.

Similar Messages

  • User Interface for bulk loading images using interMedia

    I would like to create an interface where users could bulk load images to a database. Has anyone created a web (or other) interface that would perhaps call a PL/SQL procedure or SQLloader?
    Is there a way for users to upload images from there own computers in bulk? Would they need to utilize SQLPLUS?
    While I have seen the examples and plan to create a web interface for uploading images one at a time, I have been requested to find a way for the users to upload images in bulk themselves (instead of them requesting us technical people to do it).
    Thanks for any suggestions.
    Judy

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Simon Oxbury:
    Hi,
    There's a sample on OTN that discusses loading multimedia data in bulk into the interMedia types using both SQL*Plus (with PL/SQL) and SQL*Loader. Check out the following URL: http://otn.oracle.com/sample_code/products/intermedia/htdocs/avi_bulk_loading.html
    One major difference to consider between SQL*Loader and SQL*Plus (with PL/SQL) is that SQL*Loader can load data from files on the machine running SQL*Loader, which may be a different machine than the database, although it still needs an Oracle installation. Whereas SQL*Plus with PL/SQL can load data only from directories that are accessible to the database server and that have been defined in the server using the CREATE DIRECTORY command, which requires privs. Also note there are restrictions and issues specific to both NT and Unix when it comes to access network directories from the server.
    If SQL*Loader looks like a possibility, you might want to think about a simple Java program, Perl script, or some such, to create the SQL*Loader scripts. On the other hand, if you get into Java, then you could use Java to do the upload and, at the same time, provide some level of application-specific user interaction and/or error reporting, etc. Its easy to get a list of file names in a directory using the File.list or File.listFiles methods in Java. On the other hand, if we talking LOTs of files, then SQL*Loader may turn out to be more efficient.
    In order to better understand the variety of ways in which our customers are using interMedia, we'd be very interested in knowing a little more about your application, the interMedia functionality that you are using, and how you are developing and deploying your application. If you are able to help us, please send a short email message with some information about your application, together with any comments you may have, to the Oracle interMedia Product Manager, Joe Mauro, at [email protected]. Thank you!
    Regards,
    Simon<HR></BLOCKQUOTE>
    null

  • Loading incomplete using sqlplus_exec_template.sql  in shell script

    Hi,
    I've tried to automate the dataloading by calling sqlplus_exec_template.sql for each mapping in the shell script bash. (I comment out the last exit line in the script). But the loading were always partially complete for those that take longer time, says more than 5 or 10min. I've also tried to call each mapping in different shell and got the same result. How do you work around this? Below is part of the lines in my shell script. Thanks.
    sqlplus -s test_rta/test_rta << EOF
    @sqlplus_exec_template.sql 'TEST_RTR' 'TEST_LOC' 'PLSQL' 'CONSOL_SUP_MAP' ',' ','
    @sqlplus_exec_template.sql 'TEST_RTR' 'TEST_LOC' 'PLSQL' 'CONSOL_PART_MAP' ',' ','
    EOF

    I 've tried to use :
    sqlplus username/[email protected] @C:\OWB\owb\rtp\sql\sqlplus_exec_template.sql
    rtschema OWBLOCATION SQL_LOADER CRD_APPL_MAPPING "," ","
    where OWBLOCATION I have used the deploy location of the mapping for my case, created within OWB. The value is CCS_DEPLOY.
    But the error is the same :
    ======================================================
    Stage 1: Decoding Parameters
    | location_name=CCS_DEPLOY
    | task_type=SQL_LOADER
    | task_name=CRD_APPL_MAPPING
    Stage 2: Opening Task
    declare
    ERROR at line 1:
    ORA-20001: Task not found - Please check the Task Type, Name and Location are
    correct.
    ORA-06512: at line 261
    ========================================================
    could you tell me the SQL used by WB_RT_API to get the task from runtime schema. So that I could check the correct location myself.
    Or how could I view the pl/sql of WB_RT_API_EXEC which is wrapped.
    Thx for your help.
    Rg.
    CH

  • BI UDI data load conflict using MS SQL Server and date fields

    Hi BW Experts!
    We have found some unexpected problems when we are trying to perform a data extraction process from an SQL database (non-SAP application).
    We are using the BI UDI tool (JDBC Driver/Connector).    The basic data extraction works properly, however we have some specific problems to work with SQL Server fields defined as “Date Time”.
    The JDBC driver automatically intermediate the communication and translate these fields splitting the original SQL date time field into two separated fields with suffix “_D” (for date) and “_T” (for time).
    It works perfect for extraction, but it doesn’t work well when we try to restrict the data selection based on these fields.    
    When we put a date selection into the infopackage data selection area (we already have tried several date formats), the system simply ignores these selection parameters and send a SQL statement without “WHERE” clause to DBMS.   
    Please, anybody has experienced anything like this or know somethings that could help us? 
    This is a standard limitation from SAP BI UDI?
    Thanks in advance and best regards,

    Hi Matt and Thomas
    Many thanks for your replies.
    Yes I have to do the join. Even worse I have to write an Aggregate query like this!
    Select o.F1,o.F2, m.F1,m.F2, count(*)
    from
    table@oracleServer o,
    table@microsoftSQLServer m
    where o.F1=m.F1
    group by o.F1,o.F2, m.F1,m.F2;
    These are 2 different systems (hardware & software) which actually do the same job, they produce transactions for a common business entity. Kind of, both sell tickets for the same ABC ferry company.
    I can not put them side by side on the dashboard, as I need to aggregate the data and present it maybe in a Oracle BI Report for Accounting and Financial reconciliation purposes.
    The truth is, as it is. I can't change it, is too late.
    I have to device a way to harvest both systems as they are. I don't want to move around data. I thought looking at Oracle BI I could write SQL against multiple Data Sources. I am struggling to find a way. As it seems that it can "SQL query" 1 data source at a time.
    I have been hinted on another forum (OracleTURK) to use Oracle Transparent Gateways and Generic Connectivity. http://download.oracle.com/docs/cd/B19306_01/server.102/b14232/toc.htm
    Shame, I have to pay licenses for OWB and Oracle Transparent Gateways. I thought DB vendors can do better. Why do I have to pay to access the other 50% of the market.
    I can understand the performance implications this might have. Because of it I might even be forced at the end to move data (ETL) into a separate database, slice it into partitions and manage it that way. Pitty because currenlty I only need one report out of these systems but seems like will be dear to get.
    Thank you for all your help.
    Kubilay

  • XML Bulk load

    Need help on Loading (8000)XMLs into relational and XMLType tables. Java loader using weblogic connection pool takes days to load. Any recommendations on bulk load would be helpful.

    Hi,
    You can possibly check out the Simple Bulk Loader application that the demonstrates loading of a directory of XML files into Oracle XML DB using JDBC into an XMLType Table.
    The application can be accessed at the OTN - XMLDB Sample Corner URL:
    http://otn.oracle.com/sample_code/tech/xml/xmldb/index.html
    Hope it helps
    Shefali

  • SQL Server 2012 Management Studio: XML XQuery-query the XML Blob using CTE: How to specify the coorelation name in bulk rowset?

    Hi all,
    I just started doing the XML Xquery programming in my SQL Server 2012 Management Studio. I executed the following code:
    --query the XML Blob using a CTE (pulling from the XML file each time) Products
    WITH XmlFile (Contents) AS (
    SELECT CONVERT (XML, BulkColumn)
    FROM OPENROWSET (BULK 'H:\Products.xml', SINGLE_BLOB) ) AS XmlData
    SELECT *
    FROM XmlFile
    GO
    I got the the following Msg:
    Msg 491, Level 16, State 1, Line 4
    A correlation name must be specified for the bulk rowset in the from clause.
    How can I specify the correction name for the bulk rowset in my project?
    Please kindly help, advise and respond.
    Thanks in advance,
    Scott Chang

    Hello Scott,
    You have to assign a table alias for the OPENROWSET =>
    --query the XML Blob using a CTE (pulling from the XML file each time) Products
    WITH XmlFile (Contents) AS (
    SELECT CONVERT (XML, BulkColumn)
    FROM OPENROWSET (BULK 'H:\Products.xml', SINGLE_BLOB) AS MyXML ) AS XmlData
    SELECT *
    FROM XmlFile
    GO
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Bulk Loading using remote sql statement execution

    Well, i have a different scenario. I want to bulk load the tables like we do in MySQL with LOAD LOCAL DATA sql command.
    I have a file populated with data, what sql statement would bulk load the data into specified table using that file?
    Adnan Memon

    In Oracle, you would either use the SQL*Loader utility to load data from a flat file or you would create an external table (9i and later) that loads the flat file.
    A quick example of the external table approach
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to insert BLOB datatype image using PL/SQL Procedure and SQL Loader

    Hi,
    How to insert an image into database using PL/SQL Procedure and also how to insert using SQL Loader. Please help by giving sample code and process description.
    Thanks,
    Vijay V

    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:232814159006

  • Using oracle.sql.BLOB data type in Java Class to pass in a Blob

    All,
    I'm trying to pass in a BLOB from PL/SQL to a Java Class, but the BLOB isn't passed correctly.
    When I check the length of the BLOB in PL/SQL its different from the length of the BLOB in java.
    I'm using DB 11g and the ojdbc5.jar file in my java classes.
    The java function uses the oracle.sql.BLOB type to get the parameter.
    The java class is loaded into the DB and called via a PL/SQL function.
    Kind regards,
    Nathalie

    The question is indeed a little ambigious defined ;o)
    When I pass the BLOB to the java method and invoke BLOB.getBytes() and then get the length of the BLOB in java the length of the BLOB is bigger than in PL/SQL.
    When I use the method 'getBinaryStream' and write this to a buffer, the code works.
    I will log a tar regarding the getBytes()-method to ask for more detailed information regarding the methods provided using the JDBC Drivers.
    Kind regards,
    Nathalie

  • How to get oracle 9i blob column into an itab  in sap using Native SQL

    Hi ,
    We are using SAP ECC 5.0  and we need to coonect to an oracle database ver 9i rel2.
    We need to get the data stored in a blob(pdf/jpeg) into an itab and later
    use it for futher processing.
    I am familiar with using native SQL and I wrote a stored procedure in the non sap oracle database to send the blob info into an internal table in sap.
    But the information is in hex format and the long raw of SAP does not handle this very well.
    Plz see my code below.
    data: itab_insp_drawing like zpicture_cluster(which is of type lraw - 7902 )
          occurs 100 with header line.
    EXEC SQL.
        EXECUTE PROCEDURE
           proc_get_insp_drawings  (
                   IN  :itab-aq_id,
                   IN  :itab-section_id,
                   IN  :t_in_position,
                   out :itab_insp_drawing-picture,
                   OUT :t_blob_length,
                   out :t_out_position,
                   OUT :t_status  )
       ENDEXEC.
      append itab_insp_drawing.
      while t_out_position < t_blob_length.
       EXEC SQL.
        EXECUTE PROCEDURE
           proc_get_insp_drawings  (
                   IN  :itab-aq_id,
                   IN  :itab-section_id,
                   IN  :t_in_position,
                   out :itab_insp_drawing-picture,
                   OUT :t_blob_length,
                   out :t_out_position,
                   OUT :t_status  )
       ENDEXEC.
       append itab_insp_drawing.
       endwhile.
    Any ideas of how to handle blobs from non sap oracle table. I need this blob into an itab in sap.
    Help appreciated.
    Thanks
    Mala

    Please refer the example in this link which deals with Oracle date format.
    You can finnd a command DECODE which is used for date formats. If you have a look at whole theory then you will get an idea.
    Link:[Bulk insert SQL command to transfer data from SAP to Oracle|http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bulk-insert-sql-command-to-transfer-data-from-sap-to-oracle-cl_sql_connection-3780804]

  • Loading the data from a packed decimal format file using a sql*loader.

    Hi ,
    In one of the project i'm working here i have to load the data into oracle table from a file using a Sql*loader but the problem is the data file is in the packed decimal format so please let me know if there is any way to do this....I search a lot regarding this ..If anybody faced such type of problem ,then let me the steps to solve this.
    Thanks in advance ,
    Narasingarao.

    declare
    f utl_file.file_type;
    s1 varchar2(200);
    s2 varchar2(200);
    s3 varchar2(200);
    c number := 0;
    begin
    f := utl_file.fopen('TRY','sample1.txt','R');
    utl_file.get_line(f,s1);
    utl_file.get_line(f,s2);
    utl_file.get_line(f,s3);
    insert into sampletable (a,b,c) values (s1,s2,s3);
    c := c + 1;
    utl_file.fclose(f);
    exception
    when NO_DATA_FOUND then
    if utl_file.is_open(f) then utl_file.fclose(f); ens if;
    dbms_output.put_line('No. of rows inserted : ' || c);
    end;SY.

  • Loading the data from a text file to a table using pl/sql

    Hi Experts,
    I want to load the data from a text (sample1.txt) file to a table using pl/sql
    I have used the below pl/sql code
    declare
    f utl_file.file_type;
    s varchar2(200);
    c number := 0;
    begin
    f := utl_file.fopen('TRY','sample1.txt','R');
    loop
    utl_file.get_line(f,s);
    insert into sampletable (a,b,c) values (s,s,s);
    c := c + 1;
    end loop;
    exception
    when NO_DATA_FOUND then
    utl_file.fclose(f);
    dbms_output.put_line('No. of rows inserted : ' || c);
    end;
    and my sample1.txt file looks like
    1
    2
    3
    The data is getting inserted, with below manner
    select * from sampletable;
    A     B     C
    1     1     1
    2     2     2
    3     3     3
    I want the data to get inserted as
    A     B     C
    1     2     3
    The text file that I have is having three lines, and each line's first value should go to each column
    Please help...
    Thanks

    declare
    f utl_file.file_type;
    s1 varchar2(200);
    s2 varchar2(200);
    s3 varchar2(200);
    c number := 0;
    begin
    f := utl_file.fopen('TRY','sample1.txt','R');
    utl_file.get_line(f,s1);
    utl_file.get_line(f,s2);
    utl_file.get_line(f,s3);
    insert into sampletable (a,b,c) values (s1,s2,s3);
    c := c + 1;
    utl_file.fclose(f);
    exception
    when NO_DATA_FOUND then
    if utl_file.is_open(f) then utl_file.fclose(f); ens if;
    dbms_output.put_line('No. of rows inserted : ' || c);
    end;SY.

  • Downloading BLOB to a file using pl/sql toolkit

    Created an Oracle Reports RDF file using the reports builder (9.0.2.x).
    Uploaded the file into the database in a BLOB column using the following code:
    >>>>
    SET VERIFY OFF
    DECLARE
    p_bfile BFILE ;
    p_blob BLOB ;
    BEGIN
    p_bfile := BFILENAME('CDR_REPORTS', '&1') ;
    INSERT INTO RPTIDE (RPTID, RPTMODULE) VALUES ('&1', EMPTY_BLOB()) RETURNING
    RPTMODULE INTO p_blob ;
    DBMS_LOB.FILEOPEN(p_bfile, DBMS_LOB.FILE_READONLY);
    DBMS_LOB.LOADFROMFILE(p_blob, p_bfile, DBMS_LOB.GETLENGTH(p_bfile));
    DBMS_LOB.FILECLOSE(p_bfile);
    COMMIT ;
    END ;
    <<<<<
    Now when we try to download the same file using pl/sql web toolkit (code pasted
    below), the file downloads fine (with exact same file size as before), but no
    longer can open the file in Reports Builder anymore. Get "Cannot open file"
    error in reports builder. Is it getting corrupt or am I doing something wrong?
    >>>>
    CREATE OR REPLACE PROCEDURE filedownload(p_rpt IN VARCHAR2) AS
    p_file blob;
    p_mime_type varchar2(50);
    p_offset integer := 1;
    p_len number;
    p_buf RAW(32000);
    p_buf_size integer:= 32000;
    BEGIN
    SELECT rptmodule, 'application/x-zip'
    INTO p_file, p_mime_type
    FROM rptide
    WHERE rptid = p_rpt ;
    OWA_UTIL.MIME_HEADER(p_mime_type);
    p_len := DBMS_LOB.GETLENGTH(p_file);
    WHILE p_offset < p_len LOOP
    DBMS_LOB.READ(p_file, p_buf_size, p_offset, p_buf);
    HTP.PRN(UTL_RAW.CAST_TO_VARCHAR2(p_buf));
    p_offset := p_offset + p_buf_size;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN HTP.PRN('No document specified') ;
    WHEN OTHERS THEN HTP.P('filedownload: '||SQLERRM);
    END filedownload ;
    <<<<<

    The answer to this problem was to set the NLS_LANGUAGE for the DAD to an 8-bit character set since the database charset was 8-bit. It seems, by default, the web toolkit assumes a 7-bit character set.

  • PL/SQL Bulk Loading

    Hello,
    I have one question regarding bulk loading. I did lot of bulk loading.
    But my requirement is to call function which will do some DML operation and give ref key so that i can insert to fact table.
    Because i can't use DML function in select statement. (which will give error). otherway is using autonomous transaction. which i tried working but performance is very slow.
    How to call this function inside bulk loading process.
    Help !!
    xx_f is function which is using autonmous transction,
    See my sample code
    declare
    cursor c1 is select a,b,c from xx;
    type l_a is table of xx.a%type;
    type l_b is table of xx.b%type;
    type l_c is table of xx.c%type;
    v_a l_a;
    v_b l_b;
    v_c l_c;
    begin
    open c1;
    loop
    fetch c1 bulk collect into v_a,v_b,v_c limit 1000;
    exit when c1%notfound;
    begin
    forall i in 1..v_a.count
    insert into xxyy
    (a,b,c) values (xx_f(v_a(i),xx_f(v_b(i),xx_f(v_c(i));
    commit;
    end bulkload;
    end loop;
    close c1;
    end;
    I just want to call xx_f function without autonoumous transaction.
    but with bulk loading. Please let me if you need more details
    Thanks
    yreddyr

    Can you show the code for xx_f? Does it do DML, or just transformations on the columns?
    Depending on what it does, an alternative could be something like:
    DECLARE
       CURSOR c1 IS
          SELECT xx_f(a), xx_f(b), xx_f(c) FROM xx;
       TYPE l_a IS TABLE OF whatever xx_f returns;
       TYPE l_b IS TABLE OF whatever xx_f returns;
       TYPE l_c IS TABLE OF whatever xx_f returns;
       v_a l_a;
       v_b l_b;
       v_c l_c;
    BEGIN
       OPEN c1;
       LOOP
          FETCH c1 BULK COLLECT INTO v_a, v_b, v_c LIMIT 1000;
          BEGIN
             FORALL i IN 1..v_a.COUNT
                INSERT INTO xxyy (a, b, c)
                VALUES (v_a(i), v_b(i), v_c(i));
          END;
          EXIT WHEN c1%NOTFOUND;
       END LOOP;
       CLOSE c1;
    END;John

  • Using API  to run Catalog Bulk Load - Items & Price Lists concurrent prog

    Hi everyone. I want to be able to run the concurrent program "Catalog Bulk Load - Items & Price Lists" for iProcurement. I have been able to run concurrent programs in the past using the fnd_request.submit_request API. But I seem to be having problems with the item loading concurrent program. for one thing, the program is stuck on phase code P (pending) status.
    When I run the same concurrent program using the iProcurement Administration page it runs ok.
    Has anyone been able to run this program through the backend? If so, any help is appreciated.
    Thanks

    Hello S.P,
    Basically this is what I am trying to achieve.
    1. Create a staging table. The columns available for it are category_name, item_number, item_description, supplier, supplier_site, price, uom and currency.
    So basically the user can load item details into the database from an excel sheet.
    2. use the utl_file api, create an xml file called item_load.xml using the data in the staging table. this will create the xml file used to load items in iprocurement and save it in the database directory /var/tmp/iprocurement This part works great.
    3. use the api fnd_request.submit_request to submit the concurrent program 'Catalog Bulk Load - Items & Price Lists'. This is where I am stuck. The process simply says pending or comes up with an error saying:
    oracle.apps.fnd.cp.request.FileAccessException: File /var/tmp/iprocurement is not accessable from node/machine moon1.oando-plc.com.
    I'm wondering if anyone has used my approach to load items before and if so, have they been successful?
    Thank you

Maybe you are looking for