Help in creating sql loader control file

I am having a csv file representing in this format. I have several lines like this
"XXX", "YYY","ZZZ","01/01/2005", "AAA"
So when I created the control file having, I am having problem with inserting the date.
I tried to you use the date column name
load data
infile x.cvt
into table table name
fields terminated by ","
colA
colB
colC
colD "TO_DATE(colD 'dd/mm/yyy')
does not seem to work. Please let me know what I am missing.
thanks

If you don't want to load the 5th field, you need to specify it as filler field in the control file
Load Data
Infile x.cvt
Into Table table name
Fields Terminated by ","
Optionally enclosed by '"'
(colA,
  colB,
  colC,
  colD DATE "dd/mm/yyyy",
  colE FILLER
)http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch06.htm#1006670
If you want to use the function to_date, don't forget the colon before the column name
Load Data
Infile x.cvt
Into Table table name
Fields Terminated by ","
Optionally enclosed by '"'
(colA,
  colB,
  colC,
  colD char "TO_DATE(:colD 'dd/mm/yyyy')",
  colE FILLER
)http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch06.htm#1008153
Message was edited by:
Jens Petersen

Similar Messages

  • 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.

  • 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 -> YOUR_TABLE_NAME -> SQL*Loader Parameters
    4; Set Trailing Nullcols = true :-)
    Thank you to anyone looking at this problem.
    Greetings
    Stephan

  • 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

  • Create sql loader data file dynamically

    Hi,
    I want a sample program/approach which is used to create a sql loader data file.
    The program will read table name as i/p and will use
    select stmt will column list derived from user_tab_columns from data dictionary
    assuming multiple clob columns in the column list.
    Thanks
    Manoj

    I 'm writing clob and other columns to a sql loader dat file.
    Below sample code for writing clob column is giving file write error.
    How can I write multiple clobs to dat file so that control file will handle it correctly
    offset NUMBER := 1;
    chunk VARCHAR2(32000);
    chunk_size NUMBER := 32000;
    WHILE( offset < dbms_lob.getlength(l_rec_type.narrative) )
    LOOP
    chunk := dbms_lob.substr(l_rec_type.narrative, chunk_size, offset );
    utl_file.put( l_file_handle, chunk );
         utl_file.fflush(l_file_handle);
    offset := offset + chunk_size;
    END LOOP;
         utl_file.new_line(l_file_handle);

  • 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

  • Help required to build SQL loader control file

    I have a table, That we need to load using SQL loader.
    table structure is --
    <emp_id>,<first_name>,<middle_name>,<last_name>,<sal>
    The structure of flat file is like below,
    <emp_id>|<emp_name>|<sal>
    <emp_name> field can contain space to define first name, middle name and last name,
    if no space is there means we only need to load first name. and one space means First and last name should load.
    Sample flat file--
    1001|Ram|10000
    1002|Syam Kumar Sharma|20000
    1003|Jadu Prashad|15000
    Please help me out to build the control file.
    Thanks in Advance

    Means, can use DBMS_SCHEDULER for loading data ?Yes, you can create procedures for that and let the scheduler execute them on the desired interval
    (you can even execute OS commands through DBMS_SCHEDULER).
    Read about it here:
    http://www.oracle.com/pls/db102/search?word=DBMS_SCHEDULER&partno=
    http://www.oracle-base.com/articles/10g/Scheduler10g.php
    By the way, instead of using sqlloader why not switch to using external tables?
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6611962171229
    http://www.oracle-base.com/articles/9i/SQLNewFeatures9i.php#ExternalTables
    A few other approaches (pre 10g)
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2048340300346698595
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3084681089099

  • URGENT HELP ON SQL LOADER CONTROL FILE

    Dear All,
    Please find my control file below. I need two leading zeros for the coulmn DDA_CLEARING_NUMBER. Presently its loading 18 characters. position is (0791:0808). Now i need this to be loaded with two leading zeros to the left. I need padding two zeros in front of the 18 characters. HOW CAN I DO THAT? PLEASE HELP ME IN IT.
    OPTIONS (DIRECT=FALSE,
    ROWS=30000,
    BINDSIZE=3000000,
    READSIZE=3000000,
    SKIP_UNUSABLE_INDEXES=TRUE)
    LOAD DATA
    INFILE '/xxx/xxx/xxx.dat'
    BADFILE '/xxx/xxx/xxx.bad'
    DISCARDFILE '/dev/null'
    APPEND
    INTO TABLE AAA
    WHEN MONTH_END_STATUS = 'O'
    TIME_PERIOD POSITION (0079:0086) DATE "YYYYMMDD",
    SERVICE_TYPE POSITION (0077:0078) CHAR,
    ACCOUNT_NUMBER POSITION (0001:0020) CHAR,
    MONTH_END_STATUS POSITION (0060:0060) CHAR,
    CIF_BANK POSITION (0066:0069) CHAR,
    CIF_BRANCH POSITION (0070:0074) CHAR,
    PLAN_CODE POSITION (0075:0076) CHAR,
    DDA_CLEARING_NUMBER POSITION (0791:0808) CHAR,
    TAX_ID POSITION (0516:0524) CHAR)

    Dear peterson,
    When i do what you said, its inserting nothing. not even space. Please help me in it what to do?
    thanks and regards

  • 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 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)

  • 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"
    )

  • Use of WHEN in SQL Loader Control File

    Does anyone know of a way, using the CTL file below, to NOT LOAD (i.e. discard) any record where field G is null -OR- substr(G,1,3)='CON'+ (the first 3 characters of field G are "CON")?
    The WHEN clause seems very limited in what it can test and all my attempts to use a compound condition, much less the SUBSTR function, have failed. The documentation indicates that only very simple conditions can be specified.
    (Oracle 10g, Unix)
    Thanks
    LOAD DATA
    TRUNCATE
    INTO TABLE TEST_TABLE
    WHEN (G <> '')
    FIELDS TERMINATED BY "^"
    TRAILING NULLCOLS
    A ,
    B FILLER,
    C FILLER,
    D FILLER,
    E FILLER,
    F FILLER,
    G "LTRIM(:G,'0')",
    H FILLER,
    I FILLER,
    J FILLER,
    K SYSDATE,
    L CONSTANT "SQLLDR"
    )

    Hello MTM.
    The WHEN clause in SQL*Loader, despite what you might read, doesn't seem to evaluate the value of the column you specify after SQL clauses are processed. Therefore, the only way you can guarantee to NOT LOAD a record is by using a function to raise an application error when the column data meets your criteria. You'll need to do some basic comparisons between bad data and discarded data in the bad data file to isolate these.
    You can still discard the null data using (replace ne with greater and less than)WHEN (g ne '')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.

  • Using constant values in SQL Loader control file

    Hi,
    I have a requirement where I need to migrate the data of 6 tables from MS Access into Oracle data base. I have written SQL Loader scripts so that I can create CSV files based on MS Access data and then migrate into Oracle. But in Oracle tables we have 4 common columns like Create_By, Created_Date,Updated_By and Update_Date, and those fields should be taken care by system. So, basically system should update login user ID and sysdate values in respective columns. My question here is, I do not have above mentioned common columns in MS Access tables. So, can I hard code those values in control file by saying
    Created_By CONSTANT user,
    Create_Date CONSTANT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS'),
    Updated_By CONSTANT user,
    Updated_Date CONSTANT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS')
    Please let me know your valuable suggestions.

    You do it without it constant
    --sample data file
    1,2,,
    3,4,,
    LOAD DATA
    INFILE 'D:\d.csv'
    INTO TABLE ABC
    FIELDS TERMINATED BY ","
    ( A,
      B,
      C sysdate,
      D "USER"
    )Edited by: J99 on Jul 23, 2009 12:14 PM
    OR use to avoid extra ',' in datafile.
    --sample data file
    1,2
    3,4
    LOAD DATA
    INFILE 'D:\d.csv'
    INTO TABLE ABC
    FIELDS TERMINATED BY "," TRAILING NULLCOLS
    ( A,
      B,
      C sysdate,
      D "USER"
    )

  • SQL Loader control file script - INFILE

    Hi,
    The data stored in the file "c:/test_<yyyy>_<mm>_<dd>". The <yyyy>, <mm> and <dd> has to be from sysdate. The infile gets generated on daily basis.
    LOAD DATA
    INFILE 'c:/test_'||to_char(sysdate,'yyyy')||'_'||to_char(sysdate,'mm')||'_'||to_char(sysdate,'dd').txt'
    BADFILE 'c:/test_' || to_char(sysdate,'yyyy') || '_' || to_char(sysdate,'mm') || '_' || to_char(sysdate,'dd').bad'
    I ran the above ctl from cmd prompt, it is giving an error. It is not recognizing the || symbol as concatenation.
    How can I achieve this?
    Thanks in advance.

    Thanks Hussein.
    I placed the control script in GL_TOP directory in unix OS. I created an executable (for the control script) and scheduled this concurrent program.
    OS :- HP Tru64 UNIX - 5.1b
    Database : 9.2.0.5
    Application: Oracle General Ledger (Ver 11.5.9).
    The error I am getting if I run the command "sqlldr ...." from cmd prompt is:
    sql*Loader: Release 8.1.7.0.0
    Illegal combination of non-alphanumeric characters
    INFILE 'c:/test_' || to_char(sysdate,'yyyy'.......'
    Thanks again.

Maybe you are looking for

  • Visual static or noise in Coverflow windows and Quicktime quick look icons

    I am seeing visual static in the finder cover flow window, and with mp4 quick look icons in the cover flow window. I am guessing that their is corruption in a persistent desktop or finder database or cache. Is there any way to fix this? Regards, Mike

  • Cant see or find my application bar

    Need help I cant find or see my application bar

  • How do I update apps in iTunes?

    How do i update apps in iTunes? Since the new release I can't find anything other than adds and other stuf to upsell me?

  • CSRF form field is missing

    Hi, I have a classical asp .net application which is using asp.net 4.0 architecture(using Webforms and NOT MVC). To prevent CSRF attacks I am trying to use AntiCSRF implementation given by codeplex. When I try to redirect a certain page using 'Server

  • Time-lapse playback in Aperture

    Trying to take a group of timelapsed jpegs and run them at 30 FPS as a movie clip in an Aperture Slideshow.. tried quicktime and imovie, but can't control frame rate to make it a video.. spent hrs. on this, any advice? Help please!