Different log file name in the Control file of SQL Loader

Dear all,
I get every day 3 log files with ftp from a Solaris Server to a Windows 2000 Server machine. In this Windows machine, we have an Oracle Database 9.2. These log files are in the following format: in<date>.log i.e. in20070429.log.
I would like to load this log file's data to an Oracle table every day and I would like to use SQL Loader for this job.
The problem is that the log file name is different every day.
How can I give this variable log file name in the Control file, which is used for the SQL Loader?
file.ctl
LOAD DATA
INFILE 'D:\gbal\in<date>.log'
APPEND INTO TABLE CHAT_SL
FIELDS TERMINATED BY WHITESPACE
TRAILING NULLCOLS
(SL1 DATE "Mon DD, YYYY HH:MI:SS FF3AM",
SL2 char,
SL3 DATE "Mon DD, YYYY HH:MI:SS FF3AM",
SL4 char,
SL5 char,
SL6 char,
SL7 char,
SL8 char,
SL9 char,
SL10 char,
SL11 char,
SL12 char,
SL13 char,
SL14 char,
SL15 char)
Do you have any better idea about this issue?
I thought of renaming the log file to an instant name, such as in.log, but how can I distinguish the desired log file, from the other two?
Thank you very much in advance.
Giorgos Baliotis

I don't have a direct solution for your problem.
However if you invoke the SQL loader from an Oracle stored procedure, it is possible to dynamically set control\log file.
# Grant previleges to the user to execute command prompt statements
BEGIN
dbms_java.grant_permission('bc4186ol','java.io.FilePermission','C:\windows\system32\cmd.exe','execute');
END;
* Procedure to execute Operating system commands using PL\SQL(Oracle script making use of Java packages
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
import java.io.*;
public class Host {
public static void executeCommand(String command) {
try {
String[] finalCommand;
finalCommand = new String[4];
finalCommand[0] = "C:\\windows\\system32\\cmd.exe";
finalCommand[1] = "/y";
finalCommand[2] = "/c";
finalCommand[3] = command;
final Process pr = Runtime.getRuntime().exec(finalCommand);
new Thread(new Runnable() {
public void run() {
try {
BufferedReader br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String buff = null;
while ((buff = br_in.readLine()) != null) {
System.out.println("Process out :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
catch (IOException ioe) {
System.out.println("Exception caught printing process output.");
ioe.printStackTrace();
}).start();
new Thread(new Runnable() {
public void run() {
try {
BufferedReader br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String buff = null;
while ((buff = br_err.readLine()) != null) {
System.out.println("Process err :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
catch (IOException ioe) {
System.out.println("Exception caught printing process error.");
ioe.printStackTrace();
}).start();
catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
public static boolean isWindows() {
if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
return true;
else
return false;
* Oracle wrapper to call the above procedure
CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
AS LANGUAGE JAVA
NAME 'Host.executeCommand (java.lang.String)';
* Now invoke the procedure with an operating system command(Execyte SQL-loader)
* The execution of script would ensure the Prod mapping data file is loaded to PROD_5005_710_MAP table
* Change the control\log\discard\bad files as apropriate
BEGIN
Host_Command (p_command => 'sqlldr system/tiburon@orcl control=C:\anupama\emp_join'||1||'.ctl log=C:\anupama\ond_lists.log');
END;Does that help you?
Regards,
Bhagat

Similar Messages

  • Log file in Sql*Loader

    Hi,
    Sql loader always creates the logfile with same name as .ctl file,
    but i want log file should get created in case of unsuccessful run
    not in case of successful run.
    Is this possible.
    Regards,
    SS

    I don’t think it is possible to suppress log file generation on successful run. The Log file contains a detailed summary of the load and helps you to identify successful/fail load.

  • SQL Loader: refer datafile name in the control file

    Hi All:
    Database: 10GR2
    I have a table as following:
    test (
    filename varchar2(100),
    mydata varchar2(1000)
    I am using sql loader to populate data for this table. I also need store the datafile name to column test.filename as part of dataload. How to refer datafile name in the control file?
    Again, I am processing multiple files in a batch mode. I need store datafile name in filename column so that I can know which "mydata" come from which datafile.
    Thanks in advance!
    Kevin

    As Bravid says, you can't do that from within SQL*Loader, unless the control files are dynamically generated by a script and the filename included as the default value for that particular column as a hardcoded literal.
    It's easier if you use external tables as the table definition contains the "location" which is the list of filenames it is accessing, and the value can be queried as well as being dynamically changed (though if you're dynamically changing it, then you'll programatically know the filename anyway. hint hint!)
    ;)

  • Any ways to roll over to a different log file when the current log file big

    How to roll over a log file when it reaches maximum to a different log file?
    any ways of doing this??????

    More info in the new owners....
    http://www.oracle.com/technology/pub/articles/hunter_logging.html
    And more!!!!! here to build a configuration file with filehandler properly setted to an specified size
    http://www.linuxtopia.org/online_books/programming_books/thinking_in_java/TIJ317_021.htm

  • How to create different log files for each of web applications deployed in OC4J

    Hi All,
    I am using OC4J(from Oracle) v1.0.2.2 and Windows2000. Now I want to know
    1. how to create different log files for each of my deployed web applications ?
    2. what are the advantages in running multiple instances of oc4j and in what case we should run
    multiple instances of OC4J ?
    3. how to run OC4J as Windows2000 Service rather than Windows2000 Application ?
    Thanks and Regards,
    Kumar.

    Hi Avi,
    First of all I have given a first reading to log4j and I think there will some more easy way of logging debugging messages than log4j (If you could provide me a detailed explanation of a servlet,jsp,java bean that uses log4j and how to use log4j then it will be very helpful for me). The other easy ways (if I am not using log4j) to my problem i.e creating different log files for each of web applications deployed in oc4j are
    I have created multiple instances of OC4J that are configured to run on different ports and so on each instance I have deployed a single web application . And I started the 2 oc4j instances by transferring thier error/log messages to a file. And the other way is ..
    I have download from jakarta site a package called servhelper . This servhelper is a thread that is started in a startup servlet and stopped in the destroy method of that startup servlet. So this thread will automatically capture all the system.out.println's and will print those to a file. I believe that this thread program is synchronized. So in this method I need not run multiple instances of OC4J instead each deployed web application on single instance of oc4j uses the same thread program (ofcourse a copy of thread program is put in each of the deployed web applications directories) to log messages on to different log files.
    Can you comment on my above 2 approached to logging debugging messages and a compartive explanation to LOG4J and how to use LOG4J using a simple servlet, simple jsp is appreciated ...
    Thanks and Regards,
    Ravi.

  • How to create different log files for different users in log4j

    I want to create different logs for different users, using different appenders for each user so that logs are created in his file only.
    Confusion:How to direct them to different files in my logger class

    Hi Avi,
    First of all I have given a first reading to log4j and I think there will some more easy way of logging debugging messages than log4j (If you could provide me a detailed explanation of a servlet,jsp,java bean that uses log4j and how to use log4j then it will be very helpful for me). The other easy ways (if I am not using log4j) to my problem i.e creating different log files for each of web applications deployed in oc4j are
    I have created multiple instances of OC4J that are configured to run on different ports and so on each instance I have deployed a single web application . And I started the 2 oc4j instances by transferring thier error/log messages to a file. And the other way is ..
    I have download from jakarta site a package called servhelper . This servhelper is a thread that is started in a startup servlet and stopped in the destroy method of that startup servlet. So this thread will automatically capture all the system.out.println's and will print those to a file. I believe that this thread program is synchronized. So in this method I need not run multiple instances of OC4J instead each deployed web application on single instance of oc4j uses the same thread program (ofcourse a copy of thread program is put in each of the deployed web applications directories) to log messages on to different log files.
    Can you comment on my above 2 approached to logging debugging messages and a compartive explanation to LOG4J and how to use LOG4J using a simple servlet, simple jsp is appreciated ...
    Thanks and Regards,
    Ravi.

  • Java.util.logging - different log files for different loggers

    I'm having trouble configuring Java logging to use different log files for different loggers.
    In log4j, I would do this by configuring multiple loggers each with a different appender. But how can I do this with Java (java.util.logging) logging?
    This is the basic idea of what I'd like to do:
    com.mycompany.app1.level = FINEST
    com.mycompany.app1.<log file> = logfile1.log
    com.mycompany.app2.level = ALL
    com.mycompany.app2.<log file> = logfile2.log
    Any suggestions?

    This kind of thing?
    import java.io.IOException;
    import java.util.logging.FileHandler;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import java.util.logging.SimpleFormatter;
    public class LogTest {
        private Logger app1;
        private Logger app2;
        public LogTest() {
            // setup loggers
            try {
                // first logger
                app1 = Logger.getLogger("com.mycompany.app1");
                FileHandler filehandler = new FileHandler( "logfile1.log" );
                filehandler.setFormatter(new SimpleFormatter());
                app1.addHandler(filehandler);  
                // second logger       
                app2 = Logger.getLogger("com.mycompany.app2");
                filehandler = new FileHandler( "logfile2.log" );
                filehandler.setFormatter(new SimpleFormatter());
                app2.addHandler(filehandler);  
            } catch(IOException ioex) {
                ioex.printStackTrace();
        private void logStuff() {
            app1.log(Level.SEVERE, "a message for log 1");
            app2.log(Level.SEVERE, "a message for log 2");
            app2.log(Level.WARNING, "another message for log 2");
         * @param args
        public static void main(String[] args) {
            new LogTest().logStuff();
    }

  • Create different log file with different schema by spool

    Hello,
    I want to know a way to create a different log file depend on different schema
    I have two schema on same db server
    1) schema kennam/*****/kennam
    2) schema koonhey/*****/koonhey
    by a way, I want to create a different log file name e.g. kennam.log / koonhey.log on such two schema...
    I always run @showbalance; to run showbalance.sql to create that report..
    I hope you understand what I talking about (english is not my native language........), anyone could help?
    showbalancelog.sql
    spool c:\log.log+
    spool c:\log.log
    select to_char(sysdate,'dd-mm-yyyy hh:mi:ss') from dual;
    column com_name format a20;
    select cus.tid, cus.com_name com_name, cus.com_balance,
    NVL((select sum(invoice_total) from invoice where com_id=cus.tid),0) sum_invoice,
    NVL((select sum(cheque_amount) from income where com_id=cus.tid),0) sum_income,
    cus.com_balance -
    NVL((select sum(invoice_total) from invoice where com_id=cus.tid),0) +
    NVL((select sum(cheque_amount) from income where com_id=cus.tid),0) total_balance
    from customers cus
    order by cus.tid;
    spool off

    okey I solved on this way, is anyone know another simpler way?
    be simpler part
    variable vspoolfile varchar2(20)
    declare
    username varchar2(20);
    spoolfile varchar2(50);
    begin
    select 'c:\' || user || '.log' into spoolfile from dual;
    -- spoolfile := 'c:\' || username || '.log';
    :vspoolfile := spoolfile;
    -- dbms_output.PUT_LINE(spoolfile);
    end;
    -- print :vspoolfile;
    column spoolfilecol new_value definespoolfile noprint
    select :vspoolfile spoolfilecol from dual;full content of my showbalancelog.sql file
    variable vspoolfile varchar2(20)
    declare
    username varchar2(20);
    spoolfile varchar2(50);
    begin
    select 'c:\' || user || '.log' into spoolfile from dual;
    -- spoolfile := 'c:\' || username || '.log';
    :vspoolfile := spoolfile;
    -- dbms_output.PUT_LINE(spoolfile);
    end;
    -- print :vspoolfile;
    column spoolfilecol new_value definespoolfile noprint
    select :vspoolfile spoolfilecol from dual;
    spool &definespoolfile;
    column com_name format a20;
    select cus.tid, cus.com_name com_name, cus.com_balance,
    NVL((select sum(invoice_total) from invoice where com_id=cus.tid),0) sum_invoice,
    NVL((select sum(cheque_amount) from income where com_id=cus.tid),0) sum_income,
    cus.com_balance -
    NVL((select sum(invoice_total) from invoice where com_id=cus.tid),0) +
    NVL((select sum(cheque_amount) from income where com_id=cus.tid),0) total_balance
    from customers cus
    order by cus.tid;
    spool off;

  • I cannot access firefox. but i can access it if i use another log on name from the same computer. how do i get to my bookmarks from my log on name.

    i can access firefox from a different log on name but not my own. i want to retrieve my bookmarks.

    See if you can boot into the Safe Mode.
    Safe Mode - About
    Safe Mode

  • How do i map one field to another in control file via SQL Loader

    Can someone please reply back to this question
    Hi,
    I have a flat file (student.dat delimiter %~| ) using control file (student.ctl) through sql loader. Here are the details.
    student.dat
    student_id, student_firstname, gender, student_lastName, student_newId
    101%~|abc%~|F %~|xyz%~|110%~|
    Corresponding table
    Student (
    Student_ID,
    Student_FN,
    Gender,
    Student_LN
    Question:
    How do i map student_newId field to student_id field in STUDENT DB table so that new id should be inserted in student_id column. How do i specify the mapping in control file. I dont want to create a new column in student table. Please let me know the best way to do this.
    Can someone please reply back to this question.
    My approach:
    In control file i will sepecify the below, Is this a best approach?. Do we have any othe way?
    STUDENT_ID *(:STUDENT_NEWID)*,
    STUDENT_FN,
    GENDER,
    STUDENT_LNAME,
    STUDENT_NEWID BOUNDFILLER
    Thanks
    Sunil
    Edited by: 993112 on Mar 13, 2013 12:28 AM
    Edited by: 993112 on Mar 13, 2013 12:30 AM
    Edited by: 993112 on Mar 13, 2013 12:31 AM
    Edited by: 993112 on Mar 18, 2013 2:52 AM

    OK, ok...
    Here is the sample data:
    101%~|abc%~|F %~|xyz%~|110%~|
    102%~|def%~|M %~|pqr%~|120%~|
    103%~|ghi%~|M %~|stu%~|130%~|
    104%~|jkl%~|F %~|vwx%~|140%~|
    105%~|mno%~|F %~|yza%~|150%~|Here is the control file:
    LOAD DATA
    INFILE student.dat
    TRUNCATE INTO TABLE STUDENT
    FIELDS TERMINATED BY '%~|' TRAILING NULLCOLS
      student_old  FILLER
    , student_fn
    , gender
    , student_ln
    , student_id
    )And here is the execution:
    SQL> CREATE TABLE student
      2  (
      3    student_id   NUMBER
      4  , student_fn   VARCHAR2 (10)
      5  , gender       VARCHAR2 (2)
      6  , student_ln   VARCHAR2 (10)
      7  );
    Table created.
    SQL>
    SQL> !sqlldr / control=student.ctl
    SQL*Loader: Release 11.2.0.3.0 - Production on Tue Mar 19 14:37:31 2013
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 5
    SQL> select * from student;
    STUDENT_ID STUDENT_FN                     GENDER STUDENT_LN
           110 abc                            F      xyz
           120 def                            M      pqr
           130 ghi                            M      stu
           140 jkl                            F      vwx
           150 mno                            F      yza
    SQL>:p

  • Can I have two Data Files in One control file of sql*loader tool

    hi,
    Can someone help me out. is it possible to have two Data Files in one control file of Sql*loader.
    And isit possible to run 10,000 records before lunch and 10,000 records before tea and 10,000 records before evening session by giving breaks after every 10,000 records.
    Thanks
    Ram

    Yes. You can specify two datafiles in one control file and can load using sql loader.
    I give you the sample control file.
    Load DATA
    INFILE 'TEST1.CSV'
    INFILE 'TEST2.CSV'
    TRUNCATE
    INTO TABLE TEST_P
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    (COL_1,
    COL_2,
    COL_n)
    Hope It will help you.
    -Karthik

  • Concatenate positions in control file for sql*loader utility.

    Is there a way to concatenate several character positions in a control file for sql*loader???
    example... field1 position(1:3) || position(5:7) ????
    I would rather not create any unnecessary temp tables for a straight load...

    How about...
    /code
    field1 position(1:7) char "substr(:field1, 1, 3) || substr(:field1, 5)"

  • Unknown issue while loading .dbf file by sql loader

    Hi guys,
    I am having a unknown issue while loading .dbf file by sql loader.
    I need to load .dbf data into oracle table.for this I converted .dbf file by just changing its extension as .csv . file structure after changing .dbf to .csv --
    C_N_NUMBER,COMP_CODE,CPT_CODE,C_N_AMT,CM_NUMBER
    1810/4,LKM,30,45,683196
    1810/5,LKM,30,45,683197
    1810/6,LKM,30,45,683198
    1810/7,LKM,30,135,683200
    1810/8,LKM,30,90,683201
    1810/9,LKM,1,45,683246
    1810/9,LKM,2,90,683246
    1810/10,LKF,1,90,683286
    2810/13,LKJ,1,50.5,680313
    2810/14,LKJ,1,50,680316
    1910/1,LKQ,1,90,680344
    3910/2,LKF,1,238.12,680368
    3910/3,LKF,1,45,680382
    3910/4,LKF,1,45,680395
    7910/5,LKS,1,45,680397
    7910/6,LKS,1,90,680400
    7910/7,LKS,1,45,680401
    7910/8,LKS,1,238.12,680414
    7910/9,LKS,1,193.12,680415
    7910/10,LKS,1,45,680490
    then I am loading it by sql loader.but I am getting always error below ...
    Record 1: Rejected - Error on table C_N_DETL_TAB, column CPT_CODE.
    ORA-01438: value larger than specified precision allowed for this column
    Record 2: Rejected - Error on table C_N_DETL_TAB, column CPT_CODE.
    ORA-01438: value larger than specified precision allowed for this column
    table structure-
    create table C_N_DETL_tab
    "C_N_NUMBER" VARCHAR2(13),
    "COMP_CODE" VARCHAR2(3),
    "CPT_CODE" NUMBER(4),
    "C_N_AMT" NUMBER(20,18),
    "CM_NUMBER" NUMBER(7)
    control file-
    options(skip=1)
    load data
    infile '/softdump/pc/C_N_DETL.csv'
    badfile '/softdump/pc/C_N_DETL.bad'
    discardfile '/softdump/pc/C_N_DETL.dsc'
    into table C_N_DETL_tab
    truncate
    FIELDS TERMINATED BY ","
    OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    C_N_NUMBER CHAR,
    COMP_CODE CHAR,
    CPT_CODE INTEGER,
    C_N_AMT INTEGER,
    CM_NUMBER INTEGER
    but guys when I am increasing size of all columns of tabel upto its max value then data is loaded but when I am checking column max length after data loaded then its very less..
    changed table structure-
    create table C_N_DETL_tab
    "C_N_NUMBER" VARCHAR2(130),
    "COMP_CODE" VARCHAR2(30),
    "CPT_CODE" NUMBER(32), ---- max value of number
    "C_N_AMT" NUMBER(32,18), ---- max value of number
    "CM_NUMBER" NUMBER(32) ---- max value of number
    now i ma running ...
    sqlldr express/express control=C_N_DETL.ctl log=C_N_DETL.log
    o/p-
    Table C_N_DETL_TAB, loaded from every logical record.
    Insert option in effect for this table: TRUNCATE
    TRAILING NULLCOLS option in effect
    Column Name Position Len Term Encl Datatype
    ---------- ---- ---- C_N_NUMBER FIRST * , O(") CHARACTER
    COMP_CODE NEXT * , O(") CHARACTER
    CPT_CODE NEXT 4 INTEGER
    C_N_AMT NEXT 4 INTEGER
    CM_NUMBER NEXT 4 INTEGER
    Table C_N_DETL_TAB:
    20 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.
    select max(length( CPT_CODE))from C_N_DETL_tab ---> 9
    can u tell me why I need to increase size of table columns upto max value?although length of data is soo much less.
    kindly check it..thnx in advance...
    rgds,
    pc

    No database version of course. Unimportant.
    If I recall correctly, it is 'integer external ' and you would best double quoting the alphanumerics (which you didn't ).
    Try changing integer in integer external in the ctl file.
    Sybrand Bakker
    Senior Oracle DBA

  • Upload Multiple files in SQL * Loader in one session

    Dear all,
    I want to upload multiple files using SQL*Loader in one go. In Unix its very easy as I have a quite experience of that. Could any body tell what is a way in Windows to upload multiple files in one go while using SQL * Loader. I want to run that using DOS's Batch file.
    Thanks
    Ghulam

    In Unix its very easy like we are putting $ sign.
    sqlldr userid=?????/?????
    control="/u12/cad_delta.ctl",log="/u12/full_extract/$1",data="/u12/$1",bad="/u12//full_extract/$1",errors=500,silent=feedback
    Suggest for Windows? It should read all .DAT files of the Windows Folder.
    Thanks

  • Problem with loading file with SQL loader

    i am getting a problem with loading a file with SQL loader. The loading is getting
    terminated after around 2000 rows whereas there are around 2700000 rows in the file.
    The file is like
    919879086475,11/17/2004,11/20/2004
    919879698625,11/17/2004,11/17/2004
    919879698628,11/17/2004,11/17/2004
    the control file, i am using is like:-
    load data
    infile 'c:\ran\temp\pps_fc.txt'
              into table bm_05oct06
    fields terminated by ","
    (mobile_no, fcal, frdate )
    I hope, my question is clear. Please help, in solving the doubt.
    regards.

    So which thread is telling the truth?
    Doubt with SQL loader file wih spaces
    Are the fields delimited with spaces or with commas?
    Perhaps they are a mixture of delimiters and that is where the error is coming in?

Maybe you are looking for

  • My ipod nano is not being read by my itunes account

    I have an ipod nano -  i believe it's the 6th generation - and I tried plugging it into my new laptop (it runs off of Windows 8.1), iTunes displayed a message saying that it could not read my ipod and if the problem persists I should uninstall and re

  • Weblogic./SOA server not getting started-BPEL Exception @ startup

    Hi All, Environment: Weblogic /SOA 11.1.1.4 is installed on my Windows machine with 3GB RAM. I installed the development mode and i have not configured my node manager.I just used to start the admin server and it automatically starts the managed SOA

  • Languagedependent content

    Hi, I wonder if there is a best practice how to deal with language dependent content of a BO on UI level. The concrete requirement is to have a field on a UI (e.g., some Name) that can be maintained in different languages. The field is supposed to sh

  • Recover / ReInstall only certain components from Original Factory Settings

    Hi, I assume that this was asked before but I could not find a POSt and I don't believe that this message board has a SEARCH function so I will ask (probably re-ask) it again. I would like to reinstall System Update and do NOT want top reinstall anyt

  • Tiger upgrade disks

    I have a fairly functional iMac G4 ( 800 MHz 512MB 75GB HD) which I upgraded to Tiger (10.4.11) several years ago.  I also have a iMac G5 (1.8 GHz 512MB 160 GB HD) which is running OS 10.3.9.  I'd like to upgrade the G5 to Tiger. Can I use the Tiger