SQL*LOADER control file for Multiple Tables

Dear DBA's
I am loading data throgh SQL*LOADER in Oracle. I have some problem, While
Inserting data into multiple table I have created single Control file in
following way which is giving me error, Data is stored in seprate fileswith
tablename.dat, So each tables data is stored in seprate .DAT file. So Iwant to
insert data from single control file taking data from .dat multiple files into
multiple tables. Is it possible?? or some different method
Please help me as early as possiable.
Thanks & Regards
Shailesh
CREATE TABLE T1 (
L1 VARCHAR2(10),
L2 NUMBER(10),
L4 NUMBER(10),
MYDATE DATE);
CREATE TABLE T2 (
L1 VARCHAR2(10),
L2 NUMBER(10),
L3 LONG,
L4 NUMBER(10),
MYDATE DATE)
CONTROL FILE :-
UNRECOVERABLE LOAD DATA
INFILE 't2.dat'
INSERT INTO TABLE t2
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
( l1 char,l2 char,l4 char,mydate date,l3 char(2000000))
INFILE 't1.dat'
INSERT INTO TABLE t1
FIELDS TERMINATED BY ','
OPTIONALLYENCLOSED BY '"'
TRAILING NULLCOLS
( f1 char,f2 char,f4 char))
T2.DAT
Raju,14,1,09-NOV-2000,"Has a powerful data parsing,engine which putslittle
limitation on the format of the data in thedatafile."
Manu,14,2,09-NOV-2000,"Can load data from multiple datafiles, during the same
load session. "
T1.DAT
Raj,14,1,09-NOV-2000
Mau,14,2,09-NOV-2000
null

Hi,
I tried to use your control file and got numerous erros.
try using seperate control files:
T1.CTL:
LOAD DATA
INFILE 'D:\T2.dat'
INSERT INTO TABLE t2
( l1 char,l2 char,l4 char,mydate date,l3 char(20000))
T2.CTL
LOAD DATA
INFILE 'D:\T1.dat'
INSERT INTO TABLE t1
( l1 char,l2 char,l4 char,mydate date)

Similar Messages

  • SQL-Loader Control file for Tab-delimited fields

    i want to import a text-file with TAB-DELIMITED fields and a line-break + return at the end of each record.
    a want to do this by sql-loader and a control file.
    please, can someone give me the statement:
    e.g.
    load data
    infile 'exaple.txt' .......
    (...field1, field2,....)
    thank you very much

    Case Study 3: Loading a Delimited, Free-Format File
    http://otn.oracle.com/pls/db92/db92.to_URL?urlname=http:%2F%2Fdownload-west.oracle.com%2Fdocs%2Fcd%2FB10501_01%2Fserver.920%2Fa96652%2Fch10.htm%231006907
    Modify the example and use 'terminated by whitespace' instead
    For more information on TERMINATED Fields see
    http://otn.oracle.com/pls/db92/db92.to_URL?remark=drilldown&urlname=http:%2F%2Fdownload-west.oracle.com%2Fdocs%2Fcd%2FB10501_01%2Fserver.920%2Fa96652%2Fch06.htm%231013838

  • Way to generate sql*loader ctl file from a table?

    I'm an oracle newbie. (Oracle 8i, HP Unix)Is there any way to take an existing table
    description and generate a sql*loader control file from it? If anyone has already written a procedure or knows where one can be found I'd really appreciate it. We're doing a mass conversion to oracle and would like an easy way to re-write all our loads.
    Thanks! Eileen from Polaroid.

    Hi,
    I have shell program, which will get column names from system table and create temp. control file and call sqlloader exe. and load the data automatically.
    You can customise this file, according to your needs.
    Shell Program
    if [ $# -ne 2 ]
    then
    echo " Usage : $0 table_name flat file name"
    exit
    fi
    #assigning envir. variable to unix variables
    table_name=$1
    flat_file=$2
    #creating the control file
    echo "LOAD DATA" > $table_name.ctl
    echo "INFILE '$flat_file'" >> $table_name.ctl
    echo "into table $table_name " >> $table_name.ctl
    echo "fields terminated by '\t'" >> $table_name.ctl
    #calling functions for making column name part
    #describing the table and spooling into file
    sqlplus -s $CUST_ORA_USER << sql_block
    spool $table_name.lst
    desc $table_name
    spool off
    sql_block
    # creating suitable file and add the feilds into control file
    # cutting the first line (headings)
    tail +3 $table_name.lst > temp
    rm -f $table_name.lst
    k=`wc -l < temp`
    k1=`expr $k - 1`
    #cutting the last line
    head -$k1 temp > tempx
    record_count=`wc -l < tempx`
    counter=1
    echo "(" > wxyz.ctl
    # reading file line by line
    cat tempx | while in_line=`line`
    do
    #cutting the first field
    field_name=`echo $in_line | cut -f1 -d' '`
    #calculating the no of characters
    word_cnt=`echo $in_line | wc -w`
    #calculating count in a line
    if [ $word_cnt = 2 ]
    then
    data_type=`echo $in_line | cut -f2 -d' ' | cut -f1 -d'('`
    if [ "$data_type" = "DATE" ]
    then
    data_fmt="DECODE(LENGTH(LTRIM(RTRIM(:$field_name))),'11',to_date(ltrim(rtrim(:$field_name)),'dd-mon-yyyy'),'9',to_date(ltrim(rtrim(:$field_name)),'dd-mm-yy'),'10',to_date(ltrim(rtr im(:$field_name)),'dd-mon-yy'),'yyyy/mm/dd hh24:mi:ss')"
    elif [ "$data_type" = "CHAR" ]
    then
    data_fmt="NVL(RTRIM(LTRIM(:$field_name)),' ')"
    elif [ "$data_type" = "VARCHAR2" ]
    then
    data_fmt="NVL(RTRIM(LTRIM(:$field_name)),' ')"
    else
    data_fmt="NVL(:$field_name,0) "
    fi
    else
    data_type=`echo $in_line | cut -f4 -d' ' | cut -f1 -d'('`
    if [ "$data_type" = "DATE" ]
    then
    data_fmt="DECODE(LENGHTH(LTRIM(RTRIM(:$field_name))),'11',to_date(ltrim(rtrim(:$field_name)),'dd-mon-yyyy'),'9',to_date(ltrim(rtrim(:$field_name)),'dd-mm-yy'),'10',to_date(ltrim(rt rim(:$field_name)),'dd-mon-yy'),'yyyy/mm/dd hh24:mi:ss')"
    elif [ "$data_type" = "CHAR" ]
    then
    data_fmt="NVL(RTRIM(LTRIM(:$field_name)),' ')"
    elif [ "$data_type" = "VARCHAR2" ]
    then
    data_fmt="NVL(RTRIM(LTRIM(:$field_name)),' ')"
    else
    data_fmt="NVL(:$field_name,0) "
    fi
    fi
    #if last line put );
    #else ,
    if test $record_count -eq $counter
    then
    echo $field_name \"$data_fmt\"");" >> wxyz.ctl
    else
    echo $field_name \"$data_fmt\""," >> wxyz.ctl
    fi
    #counter increamenting for each record
    counter=`expr $counter + 1`
    done
    #removing the file
    rm -f temp tempx
    cat wxyz.ctl >> $table_name.ctl
    rm -f x.ctl
    #calling the SQLLOADER
    SQLLDR $CUST_ORA_USER CONTROL=$table_name.ctl ERROR=99999999
    #removing the control file
    rm -f $table_name.ctl

  • Importing already-made SQL*Loader control files in OWB 10g

    Hi all,
    Suppose that I have a certain amount of already hand-made SQL*Loader control files, say 50 or so.
    Each of these control files have a variable quantity of fields.
    I feel really lazy, so I would like to know if it is possible to import directly these control files instead of re-typing them in the design center. That would save me a lot of time.
    Thanks !
    Burgy

    Hi Burgy
    One option is to use the sqlloader option to generate an external table from the SQLLoader control file (search for generate_only in the sqlloader documentation). If you define the external table in the database you can reverse engineer this into OWB.
    Cheers
    David

  • Define variable in SQL Loader Control File

    Hi,
    I have an input file where the first line is the header record, followed by the detail records. For the processing, I do not need to store the fields of the header record but I need a date field from this header record and store in as part of the detail record in an oracle record row.
    Is it possible to define a variable within the sql loader control file to store the value that I need in memory then use it when I do the sql insert by the sql loader?
    Thanks for any advice.

    Not sure that you can. But if your on unix/linux/mac its easy enough to write a shell script to populates the variables in a template file that you can then use as the ctl file. The perl template toolkit could be an option for that as well

  • Add "Trailing Nullcolls" to sql loader control files generated by OWB

    Hi gurus,
    I've got a problem loading data with SQL Loader. I need to add the parameter "trailing nullcols" into the SQL Loader control file generated by OWB. I don't want to do this by saving the skript on my hard disk and run it manually, so any ideas where I can put this parameter? I am using OWB 10.1 on a windows 2000 machine.
    Thanks
    Stephan

    Hi,
    I found the solution to problem.
    1; Select the mapping where you map your source flat file to a table.
    2; Right click on the mapping and select "configure"
    3; Go Sources and Targets -&gt; YOUR_TABLE_NAME -&gt; SQL*Loader Parameters
    4; Set Trailing Nullcols = true :-)
    Thank you to anyone looking at this problem.
    Greetings
    Stephan

  • Parameters / Variables in SQL Loader Control File

    Here's my problem, I have created SQL Loader control file (ctl) to load a file of employees. This loader program is registered in Oracle Applications. What I want is to pass a parameter derived from the profile like the user name of the one who executed the loader program and pass it to the loader program so that the user name info is included in the loading
    example
    input data
    123456,John,Smith
    654321,Jane,Doe
    loaded data
    123456,John,Smith,03-JUL-2009,USER13
    654321,Jane,Doe,03-JUL-2009,USER13
    the sysdate is easy because it can be defined in the column but what I really want to achieve is a parameter passed to the ctl file.
    Thanks in advance.

    Dear user!
    Please have a look at this thread.
    {thread:id=915277}
    In the last three posts I explain how to use a shellscript with AWK and SED to pass parameters to a controlfile.
    Please feel free to post again if you have some questions regarding my explanatory notes.
    Yours sincerely
    Florian W.

  • Run multiple SQL*Loader control files from command prompt

    I have written control files for 15 different tables with specific data files for each table. I have build the control files using toad for each one of them at once. Now I want to run the sql loader for all the tables one time. I know I cannot run multiple files from toad and not sure If I can run from the command prompt.
    Please let me know If I can.

    skvaish1 wrote:
    Hi,
    On unix you can create a script to runn all sqlldr at once like as followes.
    1. Create a script load_sqlldr.sh with following content.
    export ORACLE_SID=<YOUR DB_SID>
    export ORACLE_HOME=<Your Oracle Home>
    export PATH=$ORACLE_HOME/bin:$PATH
    sqlldr (Full command with parameter for 1st table) &
    sqlldr (Full command with parameter for 2nd table) &
    sqlldr (Full command with parameter for 3rd table) &
    sqlldr (Full command with parameter for 4th table) &
    sqlldr (Full command with parameter for 15th table) &
    2. Then execute the script.
    Regards1. Can I also write script load_sqlldr.sh with following content
    sqlldr user/psswd@db_name control=controlfile1.ctl
    sqlldr user/psswd@db_name control=controlfile2.ctl
    sqlldr user/psswd@db_name control=controlfile3.ctl
    sqlldr user/psswd@db_name control=controlfile15.ctl
    2. Then execute the script.

  • How to use Conditional statements in SQL Loader control file

    Hi,
    I am using sql loader to load a flat file to the table. I am using control file for this purpose as show below:
    LOAD
    INTO TABLE store_shrink
    TRUNCATE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    SITE_ID char,
    ST_SHRINK char,
    ST_REVENUE char,
    SHRINK_PR char ":ST_SHRINK/:ST_REVENUE"
    My question is this. If in the flat file the value of 'ST_REVENUE' is '0', then I want 'SHRINK_PR' to be '0' as well, and skip the calculation (:st_shrink/:st_revenue).
    How to achieve this with the conditional statement or using any Oracle function?
    Any help or suggestion is greatly appreciated.
    Thanks in advance.

    Hi there,
    I tried the following in my above query and it doesn't work somehow. Anyone has an idea? I have been on internet throughout but to no avail. Please help:
    LOAD
    INTO TABLE store_shrink
    TRUNCATE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    SITE_ID char,
    ST_SHRINK char,
    ST_REVENUE char,
    SHRINK_PR char "case (when :st_revenue<>'0.00' then :SHRINK_PR=:ST_SHRINK/:ST_REVENUE else :SHRINK_PR='0.00') end"
    )

  • Behavior of append in sql loader control file

    I've been searching for the exact behavior of the append option on the control file for sql loader and believe the following is the case
    using append means that new records will be written to the table
    what happens with records in the file that already exist in the table. Are they written to the discard or bad files or just ignored. I assume they are ignored but wasn't able to find anywhere it said that explicitly
    thanks in advance

    Actaully the table being loaded into has no keys defined. So the complete record would exist. For example the table has 3 coulumns named c1,c2, c3 and a record with the following
    abc
    def
    ghi
    If I load the table using the append method and the file contains the same record would I then have two records? Actually I can test this myself. When asking the question originally I didn't have anything setup to test it.
    Thanks for the response

  • SQL Loader Control File configuration

    Hi,
    I'm writing loader scripts for a Consulting team to use to load standard format files for customers. I want to be able to support different field separators without having to create copies of the control files for each separator variant.
    e.g.
    LOAD DATA
    INFILE "%IMPPATH%\BaseProd.txt"
    BADFILE "%IMPPATH%\BaseProd.bad"
    DISCARDFILE "%IMPPATH%\\BaseProd.dsc"
    INSERT INTO TABLE
              IMPORT_PRODUCT
         FIELDS TERMINATED BY ','
         OPTIONALLY ENCLOSED BY '"'
         TRAILING NULLCOLS
    (      PROD_CD      "UPPER(:PROD_CD)",
         PROD_DESCRP,
         SELL_PRICE)
    I'd like to be able to specify a %variable% for the FILEDS TERMINATED BY value. (The %IMPPATH% works a treat for the location of the file.)
    Anyone know how to achieve this?
    Thanks in advance.

    I have tried
    SET MYSEPARATOR=,
    and
    FIELDS TERMINATED BY '%MYSEPARATOR%'
    I then get the message in the LOG file
    Column Name Position Len Term Encl Datatype
    PROD_CD FIRST * O(") CHARACTER
    Terminator string : '%MYSEPARATOR%'
    It appears to be looking for the complete string %MYSEPARATOR% as the separator!
    I have also tried
    SET MYSEPARATOR=','
    and
    FIELDS TERMINATED BY %MYSEPARATOR%
    which gives the error
    SQL*Loader-350: Syntax error at line 9.
    Illegal combination of non-alphanumeric characters
    FIELDS TERMINATED BY %MYSEPARATOR%
    ^

  • SQL Loader Control file help!!!

    Hi All,
    I was in the process of writing a control file for sql loader for an activity i am performing and would appreciate inputs from you all.
    I have a table patient containing 44 columns, i have a column 'SEC_LANG_NAME' in which i have to insert data from a excel file.
    The excel file contains 3 columns, PATIENT_ID, NAME,SEC_LANG_NAME, i just want to load the values present in 'SEC_LANG_NAME' column in excel file into the 'SEC_LANG_NAME' coulmn in the patient table using sqlloader and the condition is that PATIENT_ID in excel file should be equal to PATIENT_ID in the patient table.
    as a first step i am converting this excel into a csv file, and then will shoot the sqlldr once i am done with control file, can someone please help me with the format of control file for this activity.
    thanks in advance,
    regards,
    Edited by: user10243788 on Jan 3, 2010 12:09 AM

    Hello user10243788.
    It appears that your intent is to load data into an existing table that contains the key data and is only lacking a column of information. SQL*Loader itself is not built to do this; what it can do is load records to tables. You will have to use a two-step approach similar to what Srini has suggested. 1) If your process is able to be run local to the database server, an external table is a great option. If your process is instead run remote to the database server, SQL*Loader will allow you to load your data file to a table. 2) You will need to run a process to update the PATIENT table.
    Here is a start of a control file based on the details that you've providedLOAD DATA
    REPLACE
    INTO patient_enhance
    FIELDS TERMINATED BY ","
    ( patient_id
    , name  FILLER
    , sec_lang_name)Hope this helps,
    Luke
    Please mark the answer as helpful or answered if it is so. If not, provide additional details.
    Always try to provide create table and insert table statements to help the forum members help you better.
    Edited by: Luke Mackey on Jan 5, 2010 12:30 PM
    oops, will have to load patient_id to do the update

  • Function for column validation in SQl Loader control file.

    Hello Gurus,
    We have an requirement to create a function to validate all date and number columns in control file, and return 0/1 accordingly to valid_column which is last column . I have developed the function which accepts the number and date type columns as parameter and return Y/N. My question is, is there any way so that the function could be created without passing any parameter to it?
    If yes, then how to call the function in control file?
    I have been searching since a while on Google to find out any solution but could find out.
    Using Oracle 11g Enterprise Edition Release 11.2.0.1.0
    Thanks!
    Edited by: Sush on Jul 5, 2012 2:23 AM
    Edited by: Sush on Jul 5, 2012 4:16 AM
    Edited by: Sush on Jul 5, 2012 7:28 AM

    Hi Srini,
    I have gone through this document and i couldn’t find out any solution. That’s why i was seeking help from you Gurus.
    Thanks for your help, i think i have learnt few new things abt SQL Loader by studying this document :)
    Thanks!

  • Sql loader control file path........

    Hello all,
    I am running the below query through sql loader from client machine.....
    saved the below query in loader.ctl file, which I kept in "D:\loader.ctl" path....
    options (skip=1)
    load data
    infile 'D:\flat.txt'
    into table GL_INTERFACE
    fields terminated by "," optionally enclosed by '"'
    *( STATUS, LEDGER_ID, USER_JE_SOURCE_NAME, USER_JE_CATEGORY_NAME, ACCOUNTING_DATE, CURRENCY_CODE, DATE_CREATED, CREATED_BY,*
    SEGMENT1, SEGMENT2, SEGMENT3, SEGMENT4, SEGMENT5, ACTUAL_FLAG, ENTERED_DR, ENTERED_CR, GROUP_ID )
    Now my doubt is, to execute the above I have to run the below command in sql loader....
    sqlldr USERID=apps/apps CONTROL=loader.ctl
    In the control file we have given the path for the data file, but * How the command (SQLLDR) identify the path of control file.?*
    Do I need to give or......?
    Is it possible to run the above loader program in client machine? or we have to run only server alone.....
    Please clarify my doubt.
    Thanks and Regards,
    Muthu

    Hi,
    The good practice is, If you are using oracle apps then register a concurrent program of type sql*loader
    put yor ctl file in $<ANY_TOP>/bin. Run Concurrent program to load the data.
    I am just givng you the hints, You search on google u will get multiple ways to do the same things.
    There are lots of ways like using of external table,UTL_FILE or Shell Script to do the same thing.
    Thanks,
    Pritam

  • SQL  LOADER CONTROL FILE

    hi,
    Can one call procedures and functions inside a control file in SQL Loader ...alternatively how can one use case inside a control file ...
    How to implement the the following code in a control file:
    SELECT CASE
    WHEN INSTR(UPPER(returnname),'SCHEDULE') > 0 THEN 'S'
    WHEN INSTR(UPPER(returnname),'RETURN') > 0 THEN 'R'
    WHEN INSTR(UPPER(RETURNNAME),'BREAKDOWN') > 0 THEN 'B'
    ELSE returnname
    END
    AS returns
    FROM tableexample
    Please let me know ..

    regarding your first question :
    data_file TT.dat :
    SCHEDULE
    RETURN
    BREAKDOWN
    HOLIDAY
    WEEKEND
    schedule
    return
    breakdown
    holiday
    weekend
    control_file TT.ctl :
    load data
    insert
    into table dummy_test
    (TEXT position(01:20) char
    ,TEXT_b position(01:20) char " decode(upper(:TEXT),'SCHEDULE','S','RETURN','R','BREAKDOWN','B',:TEXT) "
    parameter_file TT.par :
    userid=user/password
    DATA=TT.dat
    CONTROL=TT.ctl
    ERRORS=99999
    load file into table :
    sqlldr parfile=TT.par
    log-file TT.log :
    SQL*Loader: Release 8.1.6.2.0 - Production on Thu Feb 26 16:01:23 2004
    (c) Copyright 1999 Oracle Corporation. All rights reserved.
    Control File: TT.ctl
    Data File: TT.dat
    Bad File: TT.bad
    Discard File: none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 99999
    Bind array: 64 rows, maximum of 65536 bytes
    Continuation: none specified
    Path used: Conventional
    Table DUMMY_TEST, loaded from every logical record.
    Insert option in effect for this table: INSERT
    Column Name Position Len Term Encl Datatype
    TEXT 1:20 20 CHARACTER
    TEXT_B 1:20 20 CHARACTER
    SQL string for column : " decode(upper(:TEXT),'SCHEDULE','S','RETURN','R','BREAKDOWN','B',:TEXT) "
    Table DUMMY_TEST:
    10 Rows successfully loaded.
    0 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.
    Space allocated for bind array: 2816 bytes(64 rows)
    Space allocated for memory besides bind array: 0 bytes
    Total logical records skipped: 0
    Total logical records read: 10
    Total logical records rejected: 0
    Total logical records discarded: 0
    Run began on Thu Feb 26 16:01:23 2004
    Run ended on Thu Feb 26 16:01:23 2004
    Elapsed time was: 00:00:00.58
    CPU time was: 00:00:00.10
    SQL > select * from dummy_test ;
    TEXT TEXT_B
    SCHEDULE S
    RETURN R
    BREAKDOWN B
    HOLIDAY HOLIDAY
    WEEKEND WEEKEND
    schedule S
    return R
    breakdown B
    holiday holiday
    weekend weekend
    10 rows selected.
    SQL>
    Does it solve your problem ?
    Regards,
    Rainer

Maybe you are looking for

  • Creating a new workbook in Oracle Discoverer

    I am not very familiar with Oracle Discoverer but have had to be involved in it recently. What i am trying to do is create a new business area. I logged on to the Oracle Discoverer administrator and followed these steps - Create a new business area f

  • Dreamweaver-photoshop 7

    I am going to take over updating of our web site and need to know if Photoshop 7 will work with DREAMWEAVER?

  • Using TIC ASIC Features in the NI GPIB/VXI

    Hi, I am trying to utilize a feature detailed in the NI tutorial Triggering With NI-VXI of the TIC ASIC within the NI GPIB/VXI controller in my application. I am trying to generate a simple SYNC trigger (low going pulse) on VXI TTL0, map that trigger

  • Essbase OLAP error

    Hi Gurus, I have installed HSS, Essbase, et all. When I log into HSS, and go to Application group -> Essbase Cluster1 and choose one of the essbase cubes, i get this message... EPMLCM-34040:Cannot connect to olap service. cannot connect to essbase se

  • Help populating an array of objects

    New here, trying to figure this out. I'm trying to create an array of objects, then populate the array defining fields. I stripped this down as far as i could to simplify the problem but I get the following error when I compile (i tweaked the carrot