How to load multiple files into multiple tables using a Controlfile?

Hello world

I have four different tables with similar structures, get the data from four different data files. I would like to use one control file to load the data from four different files from four different tables.

Here's the DOF of the tables:

CREATE TABLE Product_Sales(  
    Year_of_Sale NUMBER,  
    Product_Type VARCHAR2(25 CHAR),  
    Product_Group VARCHAR2(25 CHAR),  
    Category_Type VARCHAR2(25 CHAR),  
    Category_Group VARCHAR2(10 CHAR),  
    Product_Count NUMBER,  
    Product_Amount NUMBER(19,2),  
    Category_Count NUMBER,  
    Category_Amount NUMBER(19,2)  
)  

CREATE TABLE Retail_Sales(  
    Year_of_Sale NUMBER,  
    Product_Type VARCHAR2(25 CHAR),  
    Product_Group VARCHAR2(25 CHAR),  
    Category_Type VARCHAR2(25 CHAR),  
    Category_Group VARCHAR2(10 CHAR),  
    Product_Count NUMBER,  
    Product_Amount NUMBER(19,2),  
    Category_Count NUMBER,  
    Category_Amount NUMBER(19,2)  
)  

You still have products_sales instead of product_sales in when your article, so it does not load anything in the product_sales table.  You have not reset the position for the first after subsequent field in the table and when clauses, then it starts looking for the first field to the position you left it in the previous section, instead of 1, so he can't find anything and does load all the data in the household_sales table.  You need to reset the position 1 for each combination of table and what clause after the first.  The first argument is optional.  Please see the corrected below control file.

DOWNLOAD THE DATA

INFILE 'output.txt '.

IN THE PRODUCT_SALES TABLE TRUNCATE

WHEN filename = "Product_Sales".

FIELDS ENDED BY ',' POSSIBLY FRAMED BY ' '.

TRAILING NULLCOLS

(

file name of FILLING,

Year_of_Sale,

Product_Type,

Product_Group,

Category_Type,

Category_Group,

Product_Count,

EXTERNAL DECIMAL Product_Amount,

Category_Count,

EXTERNAL DECIMAL Category_Amount

)

IN THE HOUSEHOLD_SALES TABLE TRUNCATE

WHEN filename = "Household_Sales".

FIELDS ENDED BY ',' POSSIBLY FRAMED BY ' '.

TRAILING NULLCOLS

(

filename FILLER POSITION (1),

Year_of_Sale,

Household_Type,

Product_Group FILLING,

Category_Type FILLING,

Category_Group FILLING,

Product_Count,

EXTERNAL DECIMAL Product_Amount,

Category_Count,

EXTERNAL DECIMAL Category_Amount

)

Tags: Database

Similar Questions

  • How to load csv file into external table

    I'm using oracle 11g xe edition.

    probably error-boy, but I can't "see

    Command line error: column 21:12

    Error report-

    SQL error: ORA-00906: lack of left parenthesis

    create the table rgc_ext

    (

    First name VARCHAR2 (20).

    name vARCHAR2 (20)

    )

    EXTERNAL ORGANIZATION

    (

    TYPE ORACLE_LOADER

    CER default DIRECTORY

    ACCESS SETTINGS

    (

    RECORDS DELIMITED BY NEWLINE

    FIELDS

    (

    First name VARCHAR2 (20).

    name vARCHAR2 (20).

    Sate DOB

    )

    )

    LOCATION 'info.csv '.

    );

    Hello

    Try with the following text:

    create the table rgc_ext

    (

    First name VARCHAR2 (20).

    name vARCHAR2 (20)

    )

    EXTERNAL ORGANIZATION

    (

    TYPE ORACLE_LOADER

    CER default DIRECTORY

    ACCESS SETTINGS

    (

    RECORDS DELIMITED BY NEWLINE

    ' fields completed by ',' EVENTUALLY ENCLOSED BY ' "'

    (

    First name VARCHAR2 (20).

    name vARCHAR2 (20).

    Sate DOB

    )

    )

    LOCATION ("info.csv")

    );

  • How to load the values into a table?

    In my jspx page, I have a combo and a table... Based on the values of the drop-down list, when I click on a button, I want to load the values into a table... The data in the table are from 5 database tables. I created a viewObject readonly... What to do to load the values from the table, I click on a button?

    Ensure that you have defined a variable to bind your view object.

    Read-only or not, this is what would make the Execute with action of parameters available.

    John

  • Load the data from a text file into a table using pl/sql

    Hi Experts,

    I want to load the data from a text file (sample1.txt) to a table using pl/sql

    I used the pl/sql code below

    ***********************************
    declare
    f utl_file.file_type;
    s varchar2 (200);
    c number: = 0;
    Start
    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. deles de lignes insérées: ' || c);
    end;

    ***************************************

    and my sample1.txt file looks like

    ***************************************
    1
    2
    3
    ***************************************

    Gets the data inserted, with way below

    Select * from sampletable;

    A, B AND C

    1-1-1
    2-2-2
    3 3 3

    I want that data to get inserted as

    A, B AND C

    1 2 3

    The text file I have is to have three lines, and the first value of each line should go to each column

    Help, please...

    Thank you
    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.

  • How to load a file into the app for IOS

    Dear friends,

    IAM creating an app for e-learning in iam android (in the AIR) by using the following code to load the respective lessons:

    var mv:Loader = new Loader();

    var req:URLRequest = new URLRequest("app:/Lessons/module/lesson1.swf");

    MV. Load (req);

    same thing iam using iOS (adobe AIR) his does not work pls help me load an external file in my application created with adobe air.

    Thank you and best regards,

    Syed Abdul Rahim

    1 make sure of course active loads (for example, lesson1.swf) are added to your panel of ' all files '.

    2. If the loaded file contains actionscript code that is not running, use:

    var mv:Loader = new Loader();

    var req:URLRequest = new URLRequest("app:/Lessons/module/lesson1.swf");

    var lc:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain,null);

    MV. Load (Req, LC);

  • APEX 5: FILE item type to BROWSE not load file into the table apex_application_temp_files

    Hello

    I am trying to load the BLOB (CSV file) into apex_application_temp_files table using the file_browse item type. I have created an example page and the added element of type file_browse, added a dynamic action, which send item to browse.

    Also added a button load that submits the page. But when I check the apex_application_temp_files of APEX sql workhop table, nothing appears.

    I purge file to "end of Session. Enclosed screen shot as well.Capture.PNG

    Thank you

    Ankit

    Hi Pierre,.

    has added a dynamic action, submitting travel item.

    How can you submit just the element go? How your dynamic action look like?

    But when I check the apex_application_temp_files of APEX sql workhop table, nothing appears.

    It is by design, because the sight of apex_application_temp_files limited to your current session. In your case at the session of constructor and not your application.

    Add a process to the page that contains the item "Browse file" when you use

    select *
      from apex_application_temp_files
     where name = :page item name;
    

    to access your downloaded BLOB.

    Concerning

    Patrick

  • SQL Loader loading data into two Tables using a single CSV file

    Dear all,

    I have a requirement where in I need to load the data into 2 tables using a simple csv file.

    So I wrote the following control file. But it loads only the first table and also there nothing in the debug log file.

    Please suggest how to achieve this.

    Examples of data

    Source_system_code,Record_type,Source_System_Vendor_number,$vendor_name,Vendor_site_code,Address_line1,Address_line2,Address_line3

    Victor, New, Ven001, Vinay, Vin001, abc, def, xyz

    Control file script

    ================

    OPTIONS (errors = 0, skip = 1)
    load data
    replace
    in the table1 table:
    fields ended by ',' optionally surrounded "" "
    (
    Char Source_system_code (1) POSITION "ltrim (rtrim (:Source_system_code)),"
    Record_type tank "ltrim (rtrim (:Record_type)),"
    Source_System_Vendor_number tank "ltrim (rtrim (:Source_System_Vendor_number)),"
    $vendor_name tank "ltrim (rtrim (:Vendor_name)),"
    )
    in the Table2 table
    1 = 1
    fields ended by ',' optionally surrounded "" "
    (
    $vendor_name tank "ltrim (rtrim (:Vendor_name)),"
    Vendor_site_code tank "ltrim (rtrim (:Vendor_site_code)),"
    Address_line1 tank "ltrim (rtrim (:Address_line1)),"
    Address_line2 tank "ltrim (rtrim (:Address_line2)),"
    Address_line3 tank "ltrim (rtrim (:Address_line3)).
    )

    the problem here is loading into a table, only the first. (Table 1)

    Please guide me.

    Thank you

    Kumar

    When you do not provide a starting position for the first field in table2, it starts with the following after a last referenced in table1 field, then it starts with vendor_site_code, instead of $vendor_name.  So what you need to do instead, is specify position (1) to the first field in table2 and use the fields to fill.  In addition, he dislikes when 1 = 1, and he didn't need anyway.  See the example including the corrected below control file.

    Scott@orcl12c > test.dat TYPE of HOST

    Source_system_code, Record_type, Source_System_Vendor_number, $vendor_name, Vendor_site_code, Address_line1, Address_line2, Address_line3

    Victor, New, Ven001, Vinay, Vin001, abc, def, xyz

    Scott@orcl12c > test.ctl TYPE of HOST

    OPTIONS (errors = 0, skip = 1)

    load data

    replace

    in the table1 table:

    fields ended by ',' optionally surrounded "" "

    (

    Char Source_system_code (1) POSITION "ltrim (rtrim (:Source_system_code)),"

    Record_type tank "ltrim (rtrim (:Record_type)),"

    Source_System_Vendor_number tank "ltrim (rtrim (:Source_System_Vendor_number)),"

    $vendor_name tank "ltrim (rtrim (:Vendor_name)).

    )

    in the Table2 table

    fields ended by ',' optionally surrounded "" "

    (

    source_system_code FILL (1) POSITION.

    record_type FILLING,

    source_system_vendor_number FILLING,

    $vendor_name tank "ltrim (rtrim (:Vendor_name)),"

    Vendor_site_code tank "ltrim (rtrim (:Vendor_site_code)),"

    Address_line1 tank "ltrim (rtrim (:Address_line1)),"

    Address_line2 tank "ltrim (rtrim (:Address_line2)),"

    Address_line3 tank "ltrim (rtrim (:Address_line3)).

    )

    Scott@orcl12c > CREATE TABLE table1:

    2 (Source_system_code VARCHAR2 (13),)

    3 Record_type VARCHAR2 (11),

    4 Source_System_Vendor_number VARCHAR2 (27),

    5 $vendor_name VARCHAR2 (11))

    6.

    Table created.

    Scott@orcl12c > CREATE TABLE table2

    2 ($vendor_name VARCHAR2 (11),)

    3 Vendor_site_code VARCHAR2 (16).

    4 Address_line1 VARCHAR2 (13),

    5 Address_line2 VARCHAR2 (13),

    Address_line3 6 VARCHAR2 (13))

    7.

    Table created.

    Scott@orcl12c > HOST SQLLDR scott/tiger CONTROL = test.ctl DATA = test.dat LOG = test.log

    SQL * Loader: release 12.1.0.1.0 - Production on Thu Mar 26 01:43:30 2015

    Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

    Path used: classics

    Commit the point reached - the number of logical records 1

    TABLE1 table:

    1 row loaded successfully.

    Table TABLE2:

    1 row loaded successfully.

    Check the log file:

    test.log

    For more information on the charge.

    Scott@orcl12c > SELECT * FROM table1

    2.

    RECORD_TYPE SOURCE_SYSTEM_VENDOR_NUMBER $VENDOR_NAME SOURCE_SYSTEM

    ------------- ----------- --------------------------- -----------

    Victor Ven001 new Vinay

    1 selected line.

    Scott@orcl12c > SELECT * FROM table2

    2.

    $VENDOR_NAME VENDOR_SITE_CODE ADDRESS_LINE1 ADDRESS_LINE2 ADDRESS_LINE3

    ----------- ---------------- ------------- ------------- -------------

    Vinay Vin001 abc def xyz

    1 selected line.

    Scott@orcl12c >

  • How to load several files DBF table 1 target using only 1 interface?

    Hello, I am a beginner in ODI and I have a problem.

    I have several DBF / Foxpro files that is stored in a directory like this:
    2010_10/account.dbf
    2010_11/account.dbf

    All DBF files have the same structure, but stored in a different folder (the folder name is < year > _ < month >)

    I managed to create an interface to load a DBF unique for the target table and the source table is hardcoded in the interface. Ideally, the interface will take place once a month.

    How can I use the same interface to load other DBF files?

    I know, if the data source is a text file, you can link the resource name to a variable, and the variable can be set to a file name. But I can't do since I use a JDBC driver to connect to the DBF file.

    Any help will be appreciated

    Hello

    I have no idea on the DBF files, yet...

    What is create a variable to build the 'months' and then pass this variable to OdiFileCopy, move this file to a specific directory. Then run your interface to load this file into your database. Once the work is successful, you can delete the file using OdiFileDelete (optional)

    Thank you
    Fati

  • Insert xml files into the table

    Hi all

    How to create an application, which allows me to download an xml file and insert the file into a table, looking something like what makes the apex, with 'data-> data-> Data Load XML Workshop'.

    I tried to create it using this link https://forums.Oracle.com/message/9170494 # 9170494

    but when loading the file and send it (current executing the "sp") sends the error "ORA-22285: file for FILEOPEN operation or non-existent directory.

    I could slightly auxiliary

    concerning

    This idea is troubling for me.

    The XML file DOES NOT CHANGE.  This is the goal.  You have a DTD/XST that defines where in the XML hierarchy, a data element is and (so) how to access it.  With this information, you can hardcode things.

    Therefore, you should have no reason for that functionality 'map the data column in the table column"of the data loader since all mappings will be always the same.

    As a simple INSERT... The SELECT statement can (and should) be used.

    (use the FUSION if you update / insert data).

    I copy + paste some of my code in a procedure that I use.

    You will need to replace the parameter name (p_filename) with the value of appropriate link (name of item)

      declare
        l_XML XMLType;
      begin
        /* get file from APEX WWV_FLOW_FILES */
        begin
            select XMLType( blob_content, 1 ) -- 1 means that the file is USACII encoded. this may need to be changed.
              into l_XML
            from wwv_flow_files where name = p_filename; -- replace this with the appropriate ITEM NAME
        exception
          when no_data_found then
            raise_application_error( -20001, 'not in FLOW: ''' || p_filename || '''' );
        end;
    
        /* you'll need to figure this one out */
        INSERT INTO T (...)
        SELECT ..
        FROM  XMLTable( '/'
    pasing l_xml
                columns
                       PATH  -- repeat for each "column" you want to extract
            );
    
       delete from wwv_flow_files where name=p_filename;
      end;
    
  • How to insert multiple lines using a single query

    Hi all

    How to insert multiple lines using a single query to the emp table?
    I have the number of rows to insert into table x. consumes a lot of time. I tried to insert several lines using a single query, but get errors. I know exactly the query to do this.


    Thank you
    Sunil

    Like this?

    SQL> create table test(id number , dt date);
    
    Table created.
    
    SQL> insert into test values(&a,&b);
    Enter value for a: 1   --- It asked me and I entered 1
    Enter value for b: sysdate  --- It asked me and I entered sysdate
    old   1: insert into test values(&a,&b)
    new   1: insert into test values(1,sysdate)
    
    1 row created.
    
    SQL> 
    

    g.

  • Loading a file into a global variable problem - really a global var text?

    Of all the documentation and the examples that I can find, it seems that it would be

    fix to create a global table [outside any function] variable to load image names

    then use these images to a slide show. I want to do the dynamic application, modify the text file as a new series of images.

    The global variable passes zero [any value] after the load event listener. Why is this?

    Is not global and world alive for the duration of the SWF?

    PARAMS. TXT:

    monthNames = January, February, March, April, may, June, July, August, September, October, November, December of & dayNames = Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday

    CODE:

    var dNames:Array = new Array();
    var mNames:Array = new Array();
    var request: URLRequest = new URLRequest("images/params.txt");
    variable var: URLLoader = new URLLoader();
    variables.dataFormat = pouvez;
    variables.addEventListener (Event.COMPLETE, completeHandler);
    Try
    {
    variables. Load (request);
    }
    catch (error: error)
    {
    trace ("unable to load URL:" + error);
    }
    trace ("2 mNames 2:" + mNames [2]);
    trace ("2 dNames 3:" + dNames [3]);
    Stop();

    function completeHandler(event:Event):void
    {
    var loader: URLLoader = URLLoader (event.target);
    dNames = loader.data.dayNames.split(",");
    mNames = loader.data.monthNames.split (",");
    trace (Loader.Data.DayNames);
    trace ("1 mNames 2:" + mNames [2]);
    trace ("1 dNames 3:" + dNames [3]);
    }

    OUTPUT:

    2 mNames 2: undefined
    2 dNames 3: undefined
    Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
    1 mNames 2: March
    1 dNames 3: Wednesday

    How to access these values after the loading of the external file, after charging?

    Thanks in advance.

    The statement you quoted all Adobe documentation is correct.

    If you want to load the data into the tables before anything else happens, then have everything that happens to run via the function completeHandler... when the data is loaded and processed in the tables.

    the command: loadFile() runs before the trace ("2:" + images [4]); command.  The loadFile function is processed and loading process BEGINS... but begins loading does not delay the main treatment to continue down the line - the loading itself becomes a secondary/background task.  The order was to run the function loadFile and the processing of this function has been completed.  If you don't believe, then add a trace...

    function loadFile (): void

    {

    vars.dataFormat = pouvez;

    vars.addEventListener (Event.COMPLETE, onComplete, false, 0, true);

    Vars.Load (new URLRequest("images/fnames.txt"));

    trace ("implementation");

    }

    If you add this trace, you will see the execution of function loadFile is completed and the following line in your code is then treatment... trace (2...)

    The addEventlistener method does not stop anything.  The addEventListener method code is assigned a monitor, not a traffic controller... it's say the monitor to indicate when the loading data are complete.  It does not do anything to stop the execution of the program.

    So if you want to wait until the data is loaded before anything else... it goes...

    function onComplete(evt:Event):void

    {

    var urlVars:URLVariables = evt.target.data;

    images = vars.data.images.split(",");

    tnails = vars.data.thumbnails.split(",");

    ................ HERE.................

    }

  • How to load 100 million lines of Table Partioned

    Hi all

    I have a job in the application of VLDB.

    I have a Table with 5 columns
    For ex - A, B, C, D, Date_Time

    I CREATED THE (DAILY) RANGE TABLE ON COLUMN (DATE_TIME) COMPARTMENTALIZED.

    CREATED THE NUMBER OF INDEXES FOR THE EX,
    INDEX ON A
    COMPOSITE ON DATE_TIME, B, C

    REQUIREMENT
    --------------------
    NEED TO LOAD ABOUT 100 MILLION RECORDS IN THIS TABLE EVERY DAY (IT WILL LOAD VIA SQL LOADER OR TEMPORARY TABLE (INSERT INTO ORIG SELECT * TEMP)...)

    QUESTION
    ---------------
    TABLE IS INDEXED, SO I NEVER AM NOT ABLE TO USE SQLLDR FEATURE DIRECT = TRUE.

    SO I WOULD LIKE TO KNOW WHAT IS THE BEST WAY OF AVILABLE TO LOAD THE DATA INTO THIS TABLE?

    Note--> don't FORGET not I can't DELETE AND CREATE INDEXES every DAY because of the HUGE AMOUNT of DATA.

    LiangGangYu wrote:
    Exchange partition would be your best friend in this case, because all the existing or to-be-bulit indexes are partitioned locally.

    Daily load,
    1. create a temporary table, ex_temp, with the same structure as the target table.
    2 load direct - sqlldr or external tables - path in the temporary table. You can do all the stuff of fantasy here to get the best performance without impact on the target table, 'ex '.
    3 build all indexes on the temporary table
    4. the swap partition the temporary table with the correct partition of the table target. This is a DDL, update of metadata. Very fast.

    ALTER TABLE CALL
    EX_partition PARTITION EXCHANGE WITH TABLE EX_temp
    INCLUDING INDEXES
    WITHOUT VALIDATION.

    Please see the documentation for more details. for example http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/partiti.htm#sthref2762

    Hello

    Do not forget that after the swap operation you should be collecting stats partition
    and if you have a lot of multiple queries partition adjust a stats table too.

    Kind regards
    Marcin Przepiorowski
    http://oracleprof.blogspot.com/

  • How to insert image from mysql into the table using php and create the checkbox in the table?

    How can I insert image from mysql into the table using php and create the checkbox for each data as a vote? Here is my code...

    WELCOME

    connect_error) {die ("connection failed:".)} $conn-> connect_error); } $sql = "SELECT no, Calon, ID, of course, the Image OF THE candidates." $result = $conn-> Query; If ($resultat-> num_rows > 0) {echo ' '; export data of each line while ($row = $result-> fetch_assoc()) {"echo"}}
    NO Candidate INFO Vote
    " . $row ["no"]. "-" . $row ["Calon"]. "
    -" . $row ['ID']. "
    -" . $row ['class']. "
    "; } ECHO ' ' ;} else {echo '0 results' ;} $conn-> close();?} >

    hope someone can help me because I am a newbie in this program... need to finish this project... Thank you.

    If you have saved the file name in the database, it's pretty simple.

    echo '' . $row['description'] . '';
    

    Is the same for the box:

    echo '';
    

    If you have saved the image file in the database, it is much more complicated. I recommend you store only the file name in the database.

  • How to convert pdf files into word?

    Hello

    How to convert pdf files into word?  do I need to purchase software?

    You can do this with the free Adobe Acrobat Reader DC but yes, you should always buy a subscription to ExportPDF.

  • How the values to insert into the table with the command insertion

    Dear all
    can someone tell me how the values to insert into the table with the command insert, I want to say I always use command insert behind my forms on what shutter release button press the button of my save, but today I had a form of 6i, where controls (textbox, combo, etc.) are delineated with directly the table with I guess than the Properties Windows , I created 3 columns in tand 3 text on forms fields, now kindly tell me how to do this fields to fill and do not insert command, I mean directly defined with table column



    Please help me its urgent

    Hello

    If the block is based on your database table, just committed the shape, then changes will be applied to the database.

    François

Maybe you are looking for

  • Warning about bad connections contains no option "I understand the risks", I can't move on

    I install Thunderbird on Windows 8.1. I am trying to add 3 accounts. When adding the second account that Thunderbird has warned by transmitting unsecured password. I clicked on "I understand the risks". No problem. When I tried to add my third accoun

  • Problem remote control Apple TV (not the App)

    Hello I have an Apple TV (3rd generation) and the remote no longer controls.  I have it odd and paired again, but still does not work.  I downloaded the Remote app, but that does not give me access settings, and that's what I have to do.  We changed

  • Virus Scan

    I visited this site and now my computer is telling me that the site has infected my computer, and he wants to do a virus scan. Is this safe to do?

  • Cannot use created for the Satellite A350-134 recovery disks

    EMM, I really hope you can help me.The laptop says that you create the disc of recovery by yourself, and that's what I did (on 2 Cds)So I wanted to reinstall my laptop and put in the first cd and booted from the CD. So I came in the Menu.Then, after

  • What card PCI adapter USB can I use on my Satellite C

    Hello My USB port of remaining work has now passed away, and I'm stuck because I can't print longer (especially children can not print their homework!) I discovered recently the understanding that I can get either the replaced motherboard (expensive