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.

Similar Messages

  • 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

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

  • 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

  • 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

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

  • SQL Loader Control File Recoverable Option in Oracle 9i

    We are migrating from Oracle 8 to Oracle 9i. We are running some of the SQL*Loader scripts. The control file uses "OPTIONS (UNRECOVERABLE)" option, which is working fine with Orace 8 whereas it is not working in
    Oracle 9i. Are these options "RECOVERABLE/UNRECOVERABLE" removed from Oracle 9i. If yes, why ? Or do we have an alternate option for the same.
    Thanks in advance.
    Balaji

    974647 wrote:
    my requirement is that for the remaining 2 columns, i want to insert text 'COLUMN_DROPPED' in backend table.Rest 8 columns should be populated as usual.First of all it is only possible if remaining 2 column datatype is string (char/nchar, varchar2/nvarchar2, clob/nclob) and are at least 14 characters. The rest is easy. Just modify last 2 fields in control file:
    column9  constant 'COLUMN_DROPPED',
    column10 constant 'COLUMN_DROPPED'SY.

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

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

  • 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

  • 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

Maybe you are looking for

  • PFS status in ALV report.

    Hi, How can we set PFS status in ALV report.Please tell the procedure. Thanks in advance.

  • Multiple email accounts on Lumia 800

    Dear All I have a question about email accounts on the Lumia 800. I have two email accounts, one linked to our website (pop 3) and also my personal Live account.  The account linked to the website can only receive (it costs more and thus was deemed u

  • TS2756 since ios6 update I can no longer connect my ipad to my iphone hotspot

    I updated both my iphone 4 and ipad 3 to ios6.  Since then I can no longer connect my ipad to my iphone personal hotspot.  I did the reset network on both devices.  It did work for one session but then I could never get it to work again.  Has anyone

  • Video Streaming from Server

    My configuration at school: 20 iPads connected by Wifi to Server ( Mac Mini Server ML ) So i can upload and download iWork-Documents via WebDav. This document pool works fine My next idea is to set up a media pool. I download a lot of relevant videos

  • Replenishment entry not flowing to COPA

    When reconciling the value field VVV52 " DM Cons st" it appears that repenishment orders are not booking any entry in COPA . for example a delivery xxxx should transfer 100 $ to COPA on acount no. yyyy. but none of that kind of delivery is posted to