SQL*Loader - How to combine 2 controlfiles to one controlfile

I have several controllfiles which each import another table from another datafile, because I don't want execute every seperat or create a batch file.... I'm looking for a way to put they all in one single controlfile.
example:
1st ctl-file:
LOAD DATA
INFILE "t1.dat"
INTO TABLE t1 REPLACE
FIELDS TERMINATED BY "     "
(c1,
c2 "to_number(:c2,'99999999999999999.99999999999999999','NLS_NUMERIC_CHARACTERS=''.,''')",
c3 date 'YYYY-MM-DD"T"HH24:MI:SS')
gQuqT     478.60636734965914     2006-12-05T11:00:49
ÜgQK     963.0277916962095     2006-12-30T08:03:00
üZfxN     465.15226622488257     2006-12-30T09:14:12
2nd ctl-file:
LOAD DATA
INFILE "t2.dat"
INTO TABLE t2 REPLACE
FIELDS TERMINATED BY "     "
(c1,
c2 "to_number(:c2,'99999999999999999.99999999999999999','NLS_NUMERIC_CHARACTERS=''.,''')")
alvwxs     13.0
poeh     15.0
zpgiht     21.0
At the examples is everytime used a id column, to ident which row should import in which table.
But at my case i need something like a where condition from which file the data should be imported....how should it look?
Can someone give me an advice how a controlfile should look which import both tables in one controlfile?
BR
roland

It is not possible to combine the last 3 columns as those columns are seperated by commas and in the SQL Loader control file you must ve specified COMMA as an delimiter. So u better have all the columns in the table plus add one more column which holds the concatenation of the 3 columns.
Vijay

Similar Messages

  • SQL*Loader - How to combine Flat File 3 columns and put into one single column

    Receive a flat file delimited by comma. Want to combine Flat File last 3 columns and put into one single column(Table).
    e.g.
    Flat File
    100,239,30,20,30
    While inserting into table want to combine last 3 columns and insert into invoice number column.
    302030

    It is not possible to combine the last 3 columns as those columns are seperated by commas and in the SQL Loader control file you must ve specified COMMA as an delimiter. So u better have all the columns in the table plus add one more column which holds the concatenation of the 3 columns.
    Vijay

  • SQL*Loader - How to set numeric seperator in Controlfile for float external

    I need to use "FLOAT EXTERNAL" instead of "to_number" and I want ensure that the correct numeric separator is set.
    At "to_number it look like:
    col1 "to_number(:col1,'99999999999999999.99999999999999999','NLS_NUMERIC_CHARACTERS=''.,''')")
    But how should I set the numeric separator at this case, without changing datatype FLOAT EXTERNAL?
    LOAD DATA
    INFILE "test.dat"
    INTO TABLE "t1" REPLACE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    "c1" FLOAT EXTERNAL
    I need a way to set the numericseparator in the controlfile, for the whole controlfile or for the "FLOAT EXTERNAL" column.
    Can someone give me an advice?
    BR
    roland

    Sure I could set it at environment, but I write a program which generate controlfiles for the datafiles, because this I want ensure that the datafiles can be correct imported independed of the environment settings.
    So a need a way to set it in the controlfile:(.

  • SQL LOADER - How to combine 3 rows into 1

    Hi,
    I have an input file composed of 4 different data types in 4 rows.
    line1 has fld1 text(100)
    line2 has fld2 number(4)
    line3 has fld3 date(10) "mm/dd/yyyy"
    line4 has fld4 date(10) "mm/dd/yyyy"
    all line has data in it.
    This is my control file:
    LOAD DATA
    INFILE "fileA.txt"
    truncate
    CONCATENATE 4
    INTO TABLE ps_vz_ppc_blng_aud
    TRAILING NULLCOLS
    ( text_fld CHAR(100) TERMINATED BY WHITESPACE
    ,num_fld INTEGER EXTERNAL(4)
    TERMINATED BY WHITESPACE
    ,begin_date DATE(10) "mm/dd/yyyy"
    TERMINATED BY WHITESPACE
    ,end_date DATE(10) "mm/dd/yyyy"
    TERMINATED BY WHITESPACE
    ,row_added_dttm     sysdate
    ,row_added_oprid "USER"
    My error: cannot insert null into num_fld.
    What did I do wrong? Terminated by whitespace did not end when the line end? Or the first field needs to be 100 characters and ends with end of line?

    That means the structure of your data is now something like:
    line1|1|01/01/2001|02/01/2001
    line2|2|01/01/2002|02/01/2002If so, you can use the following control file
    LOAD DATA
    INFILE "fileA.txt"
    truncate
    INTO TABLE ps_vz_ppc_blng_aud
    FIELDS TERMINATED BY "|" OPTIONALLY ENCLOSED BY '"'
    ( text_fld        char
    , num_fld         integer external
    , begin_date      DATE "mm/dd/yyyy"
    , end_date        DATE "mm/dd/yyyy"
    , row_added_dttm  sysdate
    , row_added_oprid EXPRESSION "USER"
    )P.S. There is no automatic notification, just come back from time to time and check for new postings.

  • SQL*Loader: How to load multi-line report data?

    Hi,
    is it possible to use SQL*Loader to load data from a hierarchical structured fixed column ASCII file like this
    001 scott
    New York 01.01.2002 1234
    Chicago 15.10.2001 9876
    002 smith
    Los Angeles 24.12.1999 5678
    Washington 01.12.1999 0000
    Chicago 01.01.2000 1111
    into one database table:
    id name city day code
    001 scott New York 01.01.2002 1234
    001 scott Chicago 15.10.2001 9876
    002 smith Los Angeles 24.12.1999 5678
    002 smith Washington 01.12.1999 0000
    002 smith Chicago 01.01.2000 1111
    The number of lines per name is unlimited, the next line starts after a separating ---- line.
    We cannot change the format of the text file to import.
    There is an example in the documentation that shows how to load a structure like the following via insert triggers:
    001 scott New York 01.01.2002 1234
    Chicago 15.10.2001 9876
    002 smith Los Angeles 24.12.1999 5678
    Washington 01.12.1999 0000
    Chicago 01.01.2000 1111
    But we have the name information on a separate header line, so I don't know if we can use a similar technique here.
    regards
    Sven

    Try enclosing your strings with e.g. a double-quote. To do so, the control file needs the following (example):
    LOAD DATA
    REPLACE
    INTO TABLE test          
    FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    id1,
    id2,
    id3,
    id4,
    )of course this does mean that your data must change...
    L.

  • SQL*Loader-350: Illegal combination of non-alphanumeric characters

    Hi all,
    how to skip a column in control file.
    i.e.
    I have a table with 10 columns and FAT file contains 11 columns.
    how to skip a last column ?
    and
    I added extra column to Table and I changed the control file too.
    but i am getting error.
    SQL*Loader-350: Syntax error at line 115.
    Illegal combination of non-alphanumeric characters
    thanks in Advance.

    Tom Kyte has an elaborate solution on his page:
    http://osi.oracle.com/~tkyte/SkipCols/index.html
    Or post the table description and the control file, so we can have a look at it.

  • Sql loader how import a file with save the actual row number in a db field

    Hey,
    how can i save the row number for each row in a file into a database field i the same table with the sql loader (sqlldr)?
    test data:
    john doe
    joe meier
    table:
    name surname line_number_in_file
    john doe 1
    joe meier 2
    and so on ... an if an line is discarded because it is empty for example it should be as this:
    test data:
    john doe
    joe meier
    table:
    name surname line_number_in_file
    john doe 1
    joe meier 3
    thanks for helpinmg and excuse my very bad english :-)
    Message was edited by:
    user527827

    but if one of the when clause faild or some rows are
    rejectet the sequence is not right.Did you read the link?
    "If a record is rejected (that is, it has a format error or causes an Oracle error), the generated sequence numbers are not reshuffled to mask this. If four rows are assigned sequence numbers 10, 12, 14, and 16 in a particular column, and the row with 12 is rejected, the three rows inserted are numbered 10, 14, and 16, not 10, 12, and 14. This allows the sequence of inserts to be preserved despite data errors. When you correct the rejected data and reinsert it, you can manually set the columns to agree with the sequence."
    also if you read multiple lines and they inserted in
    the wrong order the number from the sequence is not
    the line number...what do you mean with "reading multiple lines and wrong order?"

  • SQL Loader (how to cut data header)

    Hi there,
    [oracle 11g]
    I got the following text file:
    mod; DD.MM.YYYY; HH:MM:SS; aligned
    src; "ptv "; "15.04.2012"; "10:47:49"
    chs; "ISO8859-1"
    ver; "V1.0"
    ifv; "V1.0"
    dve; "V1.0"
    fft; "LIO"
    tbl; MENGE_FGR
    atr; BASIS_VERSION; FGR_NR; FGR_TEXT
    frm; num[9.0]; num[5.0]; char[40]
    rec;        122;     8; "VVZ"   
    rec;        123;     18; "VHZ"
    rec;        124;     13; "VTZ"    Now I am interested in the column TBL and ATR and follwing rawdata
    Do you see a way to automatically create the table MENGE_FR with columns BASIS_VERSION; FGR_NR;FGR_TEST and column types num, num, char and insert the raw data below?
    PS:OK, this is mysql ...so I need to convert this first to sql. So you should see num as number.
    Thx in advance Thorsten
    Edited by: Thorsten on 16.05.2013 07:30
    Edited by: Thorsten on 16.05.2013 07:32

    There are various ways that you could do this. I have demonstrated one method below. I created a table with two columns, then used SQL*Loader to load the data from the text file into those two columns. Skipping the header rows is optional. You could also use an external table instead, if the text file is on your server, not your client. I then used some PL/SQL to create and execute "create table" and "insert" statements. This is just some starter code. You will need to make modifications to handle other data types and such that were not in the example that you provided, but it should give you the general idea.
    SCOTT@orcl_11gR2> host type text_file.dat
    mod; DD.MM.YYYY; HH:MM:SS; aligned
    src; "ptv "; "15.04.2012"; "10:47:49"
    chs; "ISO8859-1"
    ver; "V1.0"
    ifv; "V1.0"
    dve; "V1.0"
    fft; "LIO"
    tbl; MENGE_FGR
    atr; BASIS_VERSION; FGR_NR; FGR_TEXT
    frm; num[9.0]; num[5.0]; char[40]
    rec;        122;     8; "VVZ"
    rec;        123;     18; "VHZ"
    rec;        124;     13; "VTZ"
    SCOTT@orcl_11gR2> host type test.ctl
    options(skip=7)
    load data
    infile text_file.dat
    into table tbl
    (col1 terminated by ';',
    col2 terminated by x'0a')
    SCOTT@orcl_11gR2> create table tbl
      2    (col1  varchar2(4),
      3     col2  varchar2(60))
      4  /
    Table created.
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=test.ctl log=test.log
    SQL*Loader: Release 11.2.0.1.0 - Production on Thu May 16 13:44:24 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 6
    SCOTT@orcl_11gR2> select * from tbl
      2  /
    COL1 COL2
    tbl   MENGE_FGR
    atr   BASIS_VERSION; FGR_NR; FGR_TEXT
    frm   num[9.0]; num[5.0]; char[40]
    rec          122;     8; "VVZ"
    rec          123;     18; "VHZ"
    rec          124;     13; "VTZ"
    6 rows selected.
    SCOTT@orcl_11gR2> declare
      2    v_tab   varchar2(30);
      3    v_atr   varchar2(32767);
      4    v_frm   varchar2(32767);
      5    v_sql   varchar2(32767);
      6    v_cols  number;
      7    v_next  varchar2(32767);
      8  begin
      9    select col2 into v_tab from tbl where col1 = 'tbl';
    10    select col2 || ';' into v_atr from tbl where col1 = 'atr';
    11    select col2 || ';' into v_frm from tbl where col1 = 'frm';
    12    v_sql := 'CREATE TABLE ' || v_tab || ' (';
    13    select regexp_count (col2, ';') + 1 into v_cols from tbl where col1 = 'atr';
    14    for i in 1 .. v_cols loop
    15      v_sql := v_sql || substr (v_atr, 1, instr (v_atr, ';') - 1) || ' ';
    16      v_next := substr (v_frm, 1, instr (v_frm, ';') - 1);
    17      v_next := replace (v_next, '[', '(');
    18      v_next := replace (v_next, ']', ')');
    19      v_next := replace (v_next, '.', ',');
    20      v_next := replace (v_next, 'num', 'number');
    21      v_next := replace (v_next, 'char', 'varchar2');
    22      v_sql := v_sql || v_next || ',';
    23      v_atr := substr (v_atr, instr (v_atr, ';') + 1);
    24      v_frm := substr (v_frm, instr (v_frm, ';') + 1);
    25    end loop;
    26    v_sql := rtrim (v_sql, ',') || ')';
    27    dbms_output.put_line (v_sql);
    28    execute immediate v_sql;
    29    for r in (select col2 from tbl where col1 = 'rec') loop
    30      v_sql := 'INSERT INTO ' || v_tab || ' VALUES (''';
    31      v_sql := v_sql || replace (replace (r.col2, ';', ''','''), '"', '');
    32      v_sql := v_sql || ''')';
    33      dbms_output.put_line (v_sql);
    34      execute immediate v_sql;
    35    end loop;
    36  end;
    37  /
    CREATE TABLE  MENGE_FGR ( BASIS_VERSION  number(9,0), FGR_NR  number(5,0),
    FGR_TEXT  varchar2(40))
    INSERT INTO  MENGE_FGR VALUES ('        122','     8',' VVZ')
    INSERT INTO  MENGE_FGR VALUES ('        123','     18',' VHZ')
    INSERT INTO  MENGE_FGR VALUES ('        124','     13',' VTZ')
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> describe menge_fgr
    Name                                      Null?    Type
    BASIS_VERSION                                      NUMBER(9)
    FGR_NR                                             NUMBER(5)
    FGR_TEXT                                           VARCHAR2(40)
    SCOTT@orcl_11gR2> select * from menge_fgr
      2  /
    BASIS_VERSION     FGR_NR FGR_TEXT
              122          8  VVZ
              123         18  VHZ
              124         13  VTZ
    3 rows selected.

  • SQL*LOADER how to load blanks when data is null

    I need to load data which contains null values into a table which cannot contains nulls. How can I tell SQL*LOADER to load blanks in a column when the input data is nulls?

    I think something like this in your control file should work:
    col1 char(10) nvl(col1,' ')

  • SQL*Loader - How to load only a few columns from a .csv file to ora table

    Hi there,
    Could anyone please let me know how to load few columns from a .csv
    file into a oracle table using SQL*Loader.
    I know how to create a .dat and .ctl file and run the sql loader.
    Suppose I have a .csv file with
    col1, col2, col3, col4
    and I only need to load col1 and col3 into col_a and col_b respectively
    in table_a?
    structure of table_ a
    col_a,
    col_b
    Please advice

    Try like..it i will work..
    LOAD DATA
    INFILE 'test.txt'
    LOAD DATA
    TRUNCATE INTO TABLE T1
    FIELDS TERMINATED BY ','
    (col1,
    col2 FILLER,
    col3,
    col4 FILLER
    )

  • SQL Loader-How to insert -ve & date values from flat text file into coloumn

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide.

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide. Try something like
    someDate    DATE 'DDMMYYYY'
    someNumber1      "TO_NUMBER ('s99999999.00')"
    someNumber2      "TO_NUMBER ('99999999.00s')"Good luck,
    Eric Kamradt

  • SQL*Loader: How to use Sequence and REF together?

    Hi,
    I'm getting the following error:
    SQL*Loader-418: Bad datafile datatype for column AREA_ID.
    I attempt to upload one datafile into 4 different tables.
    When executing sqlldr scott/tiger control=sqlldr_aj_new.ctl
    1) Here is my Control file (sqlldr_aj_new.ctl):
    load data
    infile 'TST_MAIN_NEW.csv'
    -- Loads table "TST_AREAS"
    into table TST_AREAS
    REPLACE
    FIELDS TERMINATED by ','
    (AREA_ID SEQUENCE,
    AREA_NAME,
    PRODUCT_ID,
    PRIORITY_ID,
    PLAN_ID,
    CREATED_BY_ID,
    AREA_DESC)
    -- Loads table "TST_TEMPLATE_SCENS"
    into table TST_TEMPLATE_SCENS
    REPLACE
    FIELDS TERMINATED by ','
    (TEMPLATE_SCEN_ID SEQUENCE,
    SCENARIO_NAME,
    MODIFIED_BY_ID,
    SCEN_TYPE_ID,
    OWNER_ID,
    PRIORITY_ID,
    SCOPE_ID,
    SCENARIO_DESC,
    AREA_ID REF(CONSTANT 'TST_AREAS', AREA_ID))
    2) Here is my data file(TST_MAIN_NEW.csv)
    B/S,105,1,plan_id_1,2222,area_desc1,CCEMC_PR_001,1111,1,2222,2,1,scenario_desc_1
    B/S,105,1,plan_id_2,2222,area_desc2,CCEMC_PR_002,1111,2,2222,2,2,scenario_desc_2
    3) Here are the tables:
    TST_AREAS
    Name Null? Type
    AREA_ID NOT NULL NUMBER(35)
    AREA_NAME CHAR(64)
    PRODUCT_ID NUMBER(35)
    PRIORITY_ID NUMBER(35)
    PLAN_ID NUMBER(35)
    CREATED_BY_ID NUMBER(35)
    AREA_DESC CHAR(1000)
    TST_TEMPLATE_SCENS
    Name Null? Type
    TEMPLATE_SCEN_ID NOT NULL NUMBER(35)
    SCENARIO_NAME CHAR(500)
    MODIFIED_BY_ID NUMBER(35)
    SCEN_TYPE_ID NUMBER(35)
    OWNER_ID NUMBER(35)
    PRIORITY_ID NUMBER(35)
    SCOPE_ID NUMBER(35)
    SCENARIO_DESC CHAR(1000)
    AREA_ID NOT NULL NUMBER(35)
    Please advise what is the reason for an error.
    Thank you very much!
    Andrey

    I don't think so.
    SQL> create table t (
      2  rowid number);
    rowid number)
    ERROR at line 2:
    ORA-00904: : invalid identifierPlease post your version number and the DDL for the table.
    Best practice in Oracle is to NEVER, EVER, store a ROWID: They can change.
    After you have solved the first problem, that you've never actually built the table, the solution to the sequence use is to make the call in your DML.
    INSERT INTO t (testcol) VALUES (<sequence_name>.NEXTVAL);

  • SQL loader : how to populate a calculated feild of a table?

    Hi All,
    I have a table which has total 92 columns, among them 6 feilds are calculated using few other fields of the same table.
    i have a csv file , which has only 86 feilds .
    during upload data using sql loader, is it possible to calculate other 6 feilds and upload them along with 86 fields ?
    Or any other method to populate the calculated values?
    Thanks in advance,
    Archana

    Hi Archana,
    You can have a script file with the required update commands and execute that script after the Loader loads the data to have them updated.
    But it is not a good practice to store the calculated values in the fields.
    Whenever required you can have them as a calculation in your select statements instead of storing them in the table.
    Unfortunately if the base values get changed you would be forced to recalculate and store them if you have them in the table.
    Regards,
    S.Muthukumar.

  • SQL LOADER: how to load CLOB column using stored function

    Hi,
    I am a newbie of sql loader. Everything seems to be fine until I hit a
    road block - the CLOB column type. I want to load data into the clob
    column using a stored function. I need to do some manipulation on the
    data before it gets saved to that column. But I got this error when I
    run the sql loader.
    SQL*Loader-309: No SQL string allowed as part of "DATA" field
    specification
    DATA is my CLOB type column.
    here is the content of the control file:
    LOAD DATA
    INFILE 'test.csv'
    BADFILE 'test.bad'
    DISCARDFILE 'test.dsc'
    REPLACE
    INTO TABLE test_table
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    codeid          BOUNDFILLER,
    reason          BOUNDFILLER,
    Checkstamp     "to_date(:CHECKSTAMP, 'mm/dd/yyyy')",
    "DATA"          "GetContent(:codeid, :reason)"
    All references are suggesting to use a file to load data on
    CLOB column but I want to use a function in which it generates
    the content to be saved into the column.
    Any help is greatly appreciated.
    Thanks,
    Baldwin
    MISICompany

    *** Duplicate Post ... Please Ignore ***

  • Sql loader, how to get decimals into the database?

    oracle 10.2
    we have data of the form
    1.10
    1.11
    we are using "decimal external" in the control file.
    The table is a straight number field
    I did a test where I created a table with a number field and without and precision and did regular inserts. I got the decimal values.
    so I did
    create table x (y number);
    insert into x values (1.10);
    insert into x values (1.11);
    and i got back
    1.1
    1.11
    when we sql load we get
    1
    1

    Why use decimal external then? What's wrong with leaving the field as number?

Maybe you are looking for

  • [Solved]Lighttpd and php/fcgi

    I installed and configured lighttpd and php/fcgi exactly as found http://wiki.archlinux.org/index.php/Lig … nd_Non-SSL except for: ssl and eaccelerator. I am also running php with the lighttpd user instead of phpuser. I have done chmod 775 for /var/r

  • Issue with installation of ofm application adapter

    Hi, I'm new to application adapter for SAP in 11g. I was working on an integration scenario between oracle-ebs and sap using ofmw 11g (11.1.1.4). When I'm trying to install ofm_adapters_application_generic_11.1.1.4.0 (downloaded from OTN). When execu

  • How do I go back to OSX6.8? without losing data

    I just upgraded to Mountain Lion. I'm not happy. None of my ancient (power PC) applications work anymore and I've got to spend a fortune on new versions of Photoshop, Microsoft Office etc. Mountain Lion has annoying features, like the trackpad works

  • Page-Flip component: Varying page sizes?

    Hi all, I have a question for you about the page-flip component. Is it possible to make the pages within a single book different sizes? In other words, could I have a cover page that's 500 x 500, and behind it a page that's 550 x 500, and behind that

  • I phone 6 screen shows bright colored line at right long edge

    My iphone 6 (space gray, 64 GB) shows some distorted colors (they vary) along the right long edge of the screen (facing it in normal orientation). Just want to know if this is an unusual problem; it's become more noticeable in the past 3 weeks, espec