Sql*loader in batch script

Hi,
I am calling a sqlloader and a procedure within a loop inside a batch script.
Sometimes, The sqlloader fails and subsequent procedure fails, I am not able move to the next iteration.
How to catch oracle errors in batch script
Thx.

hi,
My batch script is something like this.
I want to catch errors when
1. sql*loader throws error
2. when my pl/sql throws error.
I welcome any suggestions to improve this code.
d:
echo cd Data\Scripts
for %%f in (D:\Data\DELIVERY_NOTE\*.csv) Do (
echo conn config/config;
echo delete from SQLLOAD_DELIVERY_STAGE;
)| sqlplus -s /nolog
sqlldr USERID=config/config control=D:\Data\Scripts\loaddata_del.ctl skip=2 data=%%f
echo conn config/config;
echo exec DELIVERY_NOTE_PKG.Populate_Del_Note_stage;
echo exec DELIVERY_NOTE_PKG.PROCESS_DELIVERY_NOTE;
)| sqlplus -s /nolog
move %%f D:\Data\Processed_Delivery\
cd D:\Data\processed_Delivery\
rename *.csv *.csv.processed
cd d:\Data\scripts\
echo #############
echo PROCESSED THE FILE %%f AT %data% %time%
echo ############
)

Similar Messages

  • SQL Loader and Batch ID

    Hi All,
    In our application, we are allowing user to upload data using excel sheet in UI.
    We are using PHP script in UI and using SQL Loader to load data from excel sheet to temp_table.
    The temp_table has a primary key.
    Here my question is , Is there any way to put some batch id for every upload in that table in automatic way ?
    so that we can easily extract the data by using batch id
    we are using Oracle 11g.

    All that does is load a constant value, in which case you might as well just use constant 815 in your control file. If you want to automatically increment the value for each batch, then you need to use a different method.
    Please see the example below. Prior to each data load, it loads the next value of the sequence into a separate table, then selects that value during the data load. Note that a SQL*Loader expression that uses select must be enclosed within parentheses within the double quotes.
    SCOTT@orcl_11gR2> host type test1.dat
    1 Prod1
    2 Prod2
    3 Prod3
    4 Prod4
    5 Prod5
    SCOTT@orcl_11gR2> host type test2.dat
    6 Prod6
    7 Prod7
    8 Prod8
    SCOTT@orcl_11gR2> host type batch.ctl
    options(load=1)
    load data
    replace
    into table batch_tab
    (batch_id expression "test_seq.nextval")
    SCOTT@orcl_11gR2> host type data.ctl
    load data
    append
    into table temp_table
    fields terminated by whitespace
    trailing nullcols
    (p_id,
    p_name,
    batch_id expression "(select batch_id from batch_tab)")
    SCOTT@orcl_11gR2> create table temp_table
      2    (p_id      number primary key,
      3     p_name    varchar2(6),
      4     batch_id  number)
      5  /
    Table created.
    SCOTT@orcl_11gR2> create sequence test_seq
      2  /
    Sequence created.
    SCOTT@orcl_11gR2> create table batch_tab
      2    (batch_id  number)
      3  /
    Table created.
    SCOTT@orcl_11gR2> -- first load:
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=batch.ctl log=batch1.log
    SQL*Loader: Release 11.2.0.1.0 - Production on Fri Apr 19 17:16:33 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 1
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=data.ctl data=test1.dat log=test1.log
    SQL*Loader: Release 11.2.0.1.0 - Production on Fri Apr 19 17:16:33 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 5
    SCOTT@orcl_11gR2> select * from batch_tab
      2  /
      BATCH_ID
             1
    1 row selected.
    SCOTT@orcl_11gR2> select * from temp_table
      2  /
          P_ID P_NAME   BATCH_ID
             1 Prod1           1
             2 Prod2           1
             3 Prod3           1
             4 Prod4           1
             5 Prod5           1
    5 rows selected.
    SCOTT@orcl_11gR2> -- second load:
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=batch.ctl log=batch2.log
    SQL*Loader: Release 11.2.0.1.0 - Production on Fri Apr 19 17:16:33 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 1
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=data.ctl data=test2.dat log=test2.log
    SQL*Loader: Release 11.2.0.1.0 - Production on Fri Apr 19 17:16:33 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 3
    SCOTT@orcl_11gR2> select * from batch_tab
      2  /
      BATCH_ID
             2
    1 row selected.
    SCOTT@orcl_11gR2> select * from temp_table
      2  /
          P_ID P_NAME   BATCH_ID
             1 Prod1           1
             2 Prod2           1
             3 Prod3           1
             4 Prod4           1
             5 Prod5           1
             6 Prod6           2
             7 Prod7           2
             8 Prod8           2
    8 rows selected.

  • SQL LOADER and SHELL SCRIPT ISSUE

    Hello Guys,
    I know this not the right forum but i am not sure where i should post this.
    Pelase help
    I am running a shell script which is giving me error
    Username:SQL*Loader-128: unable to begin a session
    ORA-01017: invalid username/password; logon denied
    SQL*Loader: Release 10.2.0.4.0 - Production on Thu Nov 19 13:02:04 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    SQL*Plus: Release 10.2.0.4.0 - Production on Thu Nov 19 13:02:06 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Enter user-name:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    0 rows updated.
    Commit complete.
    SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition
    SQL> SQL> Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options Thu Nov 19 13:02:06 EST 2009In shell script i have used the same username and passwd which i am using from command line
    the shell script is calling sql loader to load file
    and for that also the username and passwd is same.
    i am able to run sqlldr command from command line dont knw why here its giving error
    here is my shell script
    set -a
    . $HOME/.edw.env
    . $admlib/checklib.sh
    LOGDIR=$admsrc/sigma6/ppadala/copg
    LOGFILE=${LOGDIR}/log/test`date '+%m%d'`.xtr
    DB_USER=copg
    DB_PWD=copg
    set +a
    cd $LOGDIR
    if test ! -f $admsrc/sigma6/ppadala/copg/DM_Daily_EFolderCloseCancel_Report_11192009.txt
    then
       echo "Error: DM_Daily_EFolderCloseCancel_Report_11192009.txt does not exist and/or is not a regular file." >> ${LOGFILE}
       exit 1
    fi
    echo 'End of Checking for the existence of the file - Successful'>> ${LOGFILE}
    sqlldr control=$admsrc/sigma6/ppadala/copg/Close_Cancle.ctl log=$admsrc/sigma6/ppadala/copg/Close_cancle.log
    userid=${DB_USER}/${DB_PWD} silent=\(HEADER,FEEDBACK,DISCARDS\)>> ${LOGFILE} 2>&1
    case $? in 0) :;;1|3) echo "Error: SQL Loader" >> ${LOGFILE}
         exit 1;;
    esac
    sqlplus << EOD
    ${DB_USER}/${DB_PWD}
    @Close_Cancle.sql
    EOD
    if [ $? -ne 0 ]
    then
        echo "Error: SQL Plus for script Processing" >> ${LOGFILE}
        echo "Resi Unit Scheduling Report Refresh failed" >> ${LOGFILE}
    fi
    ) > ${LOGFILE} 2>&1
    echo `date` >> ${LOGFILE}
    if [ -f ${LOGFILE} ]
    then
    mail -s "Resi Unit Scheduling" "[email protected]" < ${LOGFILE}
    sleep 3
    `ck_error ${LOGFILE}`
    fiplease help guys
    thanks

    Thanks for the reply
    In Close_cancle.log also its the same msg which i posted.
    logon denied..............
    and this is the log file contents when i do set - X on
    + cd /u2144009/src/sigma6/ppadala/copg
    + test ! -f
    + /u2144009/src/sigma6/ppadala/copg/DM_Daily_EFolderCloseCancel_Report_1
    + 1192009.txt echo End of Checking for the existence of the file -
    + Successful
    + 1>> /u2144009/src/sigma6/ppadala/copg/log/test1119.xtr
    + sqlldr control=/u2144009/src/sigma6/ppadala/copg/Close_Cancle.ctl
    + log=/u2144009/src/sigma6/ppadala/copg/Close_cancle.log
    Username:SQL*Loader-128: unable to begin a session
    ORA-01017: invalid username/password; logon denied
    SQL*Loader: Release 10.2.0.4.0 - Production on Thu Nov 19 17:32:17 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    + userid=copg/copg silent=(HEADER,FEEDBACK,DISCARDS)
    + 1>> /u2144009/src/sigma6/ppadala/copg/log/test1119.xtr 2>& 1
    + :
    + sqlplus
    + 0<<
    copg/copg
    @Close_Cancle.sql
    SQL*Plus: Release 10.2.0.4.0 - Production on Thu Nov 19 17:32:58 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Enter user-name:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    0 rows updated.
    Commit complete.
    SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition
    SQL> SQL> Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    + [ 0 -ne 0 ]
    Thu Nov 19 17:32:59 EST 2009Edited by: user10647455 on Nov 19, 2009 2:35 PM

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

  • Error while calling sql loader from shell script.

    In the table DBMS_SCHEDULER_JOB_RUN_DETAILS im getting the error as ""SQL*Loader-128: unable to begin a session ORA-01017: invalid username/password; logon denied""....do we need previliges for creating session of the db user????.....or wht other settings we require to do.....if the username and password used is right.

    user1122577 wrote:
    SQL*Loader-128: unable to begin a session ORA-01017: invalid username/password; logon deniedI don't know, but somehow the error you recived looks like ORA-01017 : )
    [oracle@dell ~]$ sqlplus ring/ring
    SQL*Plus: Release 10.2.0.4.0 - Production on Thu Jul 22 11:50:58 2010
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, Data Mining and Real Application Testing options
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, Data Mining and Real Application Testing options
    [oracle@dell ~]$
    [oracle@dell ~]$
    [oracle@dell ~]$ sqlldr ring/ring
    control = i don't have it
    SQL*Loader: Release 10.2.0.4.0 - Production on Thu Jul 22 11:51:08 2010
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    SQL*Loader-500: Unable to open file (i don't have it.ctl)
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: No such file or directory
    [oracle@dell ~]$
    [oracle@dell ~]$
    [oracle@dell ~]$ sqlldr ring/wrongpassword
    control = i don't have it again
    SQL*Loader: Release 10.2.0.4.0 - Production on Thu Jul 22 11:51:38 2010
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    SQL*Loader-128: unable to begin a session
    ORA-01017: invalid username/password; logon denied
    [oracle@dell ~]$

  • SQL loader and commit

    Hi,
    I am trying to execute a sql loader script that populates many tables. The order of the tables in the script is very important because the table of the last table has a constraint with the first table of the script. So I need that sqlloader executes a commit after the filling of the first tables because if sql loader executes the script simply as it is written the last tables launches an error because the constraint is violated (the last table sees the first one empty).
    How can I force a commit after a filling in sql loader?
    The sctructure of the tables was not defined by me so I must not modify it (constraint included).
    Thanks, bye bye.

    Hi,
    If you have to enable/disable manually the constraints you can execute:
    DECLARE
      v_ds_action VARCHAR2(7);
    BEGIN
      v_ds_action := 'DISABLE';
        FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'R') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'C') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
    FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'U') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'P') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
    END;
    DECLARE
      v_ds_action VARCHAR2(7);
    BEGIN
      v_ds_action := 'ENABLE';
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'P') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'U') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'C') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'R') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
    END;
    /Regards,

  • Sql*loader converst float to scientific format.

    hi all,
    I have a table x with a column "colx" defined as a float(64). this column has values in it as follows: x.colx = 12345678.9123456
    I create another table y with, you guessed it, "coly" as float(64).
    If I create a sql*loader dat file called x2y.dat with the float data and load it into sql*loader as a float it converts it to scientific format.
    Is there a way of avoiding this conversion.
    Thanks all in advanced,
    signed, oracle tard.

    All, just some additional info that I dug up on Metalink that will help when unloading data from an oracle db and inserting it into another db using sql*loader. This script will ensure the float is preserved.
    rocr
    -- unload_fixed.sql
    set tab off
    set heading off feedback off echo off verify off
    set space 1 pagesize 0 linesize 120
    accept owner prompt 'What schema owns the table to be unloaded? '
    accept table_name prompt 'What table is to be unloaded? '
    accept default_precision prompt 'No. of digits for precision: '
    accept default_scale prompt 'No. of digits for scale? '
    -- Generate the unload script
    spool unload_fixed2.sql
    select 'SET HEADING OFF FEEDBACK OFF ECHO OFF VERIFY OFF'||chr (10)||
    'SET SPACE 0 PAGESIZE 0 TERMOUT OFF TRIMSPOOL ON'
    from dual;
    -- Calculate the sum of all output field lengths and set the output record size
    select 'SET LINESIZE '||
    (sum (decode (data_type,
    'CHAR', data_length,
    'VARCHAR', data_length,
    'VARCHAR2', data_length,
    'DATE', 14,
    'NUMBER', decode (data_precision, '',
    &default_precision + 2,
    greatest (data_precision - data_scale, 1) +
    decode (data_scale, 0, 0, 1) + data_scale) + 1,
    'FLOAT', &default_precision + 2,
    data_length)))
    from dba_tab_columns
    where owner = upper ('&&owner') and
    table_name = upper ('&&table_name');
    -- Generate an appropriate SQL*Plus COLUMN command to control
    -- formatting of each output field
    select 'COLUMN '||rpad ('"'||column_name||'"', 32)||' FORMAT '||
    rpad (decode (data_type,
    'CHAR', 'A'||data_length,
    'VARCHAR2', 'A'||data_length,
    'VARCHAR', 'A'||data_length,
    'DATE', 'A14',
    'NUMBER', decode (data_precision, '',
    rpad ('0', &default_precision - &default_scale,
    '9')||'.'||rpad ('9', &default_scale, '9'),
    rpad ('0', greatest (data_precision -
    data_scale, 1), '9')||decode (data_scale, 0, '',
    '.')||decode (data_scale, 0, '',
    rpad ('9', data_scale, '9'))),
    'FLOAT', rpad ('0', &default_precision - &default_scale,
    '9')||'.'||rpad ('9', &default_scale, '9'),
    'ERROR'),40)||' HEADING ''X'''
    from dba_tab_columns
    where owner = upper ('&&owner') and
    table_name = upper ('&&table_name')
    order by column_id;
    -- Generate the actual SELECT statement to unload table data
    select 'SPOOL &&owner..&&table_name..DAT' from dual;
    column var1 noprint
    column var2 noprint
    select 'a' var1, 0 var2, 'SELECT '
    from dual
    union
    select 'b', column_id, decode (column_id, 1, ' ', ' , ')||
    decode (data_type, 'DATE', 'to_char ('||'"'||column_name||
    '"'||', ''YYYYMMDDHH24MISS'') '||'"'||column_name||'"',
    '"'||column_name||'"')
    from dba_tab_columns
    where owner = upper ('&&owner') and
    table_name = upper ('&&table_name')
    union
    select 'c', 0, 'FROM &&owner..&&table_name'
    from dual
    union
    select 'd', 0, ';'
    from dual
    order by 1,2;
    select 'SPOOL OFF' from dual;
    select 'SET TERMOUT ON' from dual;
    spool off
    -- Generate the SQL*Loader control file
    set lines 120 pages 0
    spool &&owner..&&table_name..CTL
    select 'a' var1, 0 var2, 'OPTIONS(DIRECT=TRUE)'
    from dual
    union
    select 'b', 0, 'LOAD DATA'
    from dual
    union
    select 'c', 0, 'INFILE ''&&owner..&&table_name..DAT'''
    from dual
    union
    select 'd', 0, 'BADFILE &&owner..&&table_name..BAD'
    from dual
    union
    select 'e', 0, 'DISCARDFILE &&owner..&&table_name..DSC'
    from dual
    union
    select 'f', 0, 'DISCARDMAX 999'
    from dual
    union
    select 'm', 0, 'INTO TABLE &&owner..&&table_name'
    from dual
    union
    select 'n', column_id, rpad (decode (column_id, 1, '(', ',')||
    '"'||column_name||'"', 31)||
    decode (data_type,
    'CHAR', 'CHAR('||data_length||')',
    'VARCHAR', 'CHAR('||data_length||')',
    'VARCHAR2', 'CHAR('||data_length||')',
    'DATE', 'DATE(14) "YYYYMMDDHH24MISS"',
    'NUMBER', 'DECIMAL EXTERNAL ('||decode (data_precision,
    '', &default_precision + 2,
    greatest (data_precision - data_scale, 1) +
    decode (data_scale, 0, 0, 1) + data_scale + 1)||')',
    'FLOAT', 'DECIMAL EXTERNAL ('||to_char (&default_precision +
    2)||')', 'ERROR--'||data_type)||' NULLIF ("'||
    column_name||'" = BLANKS)'
    from dba_tab_columns
    where owner = upper ('&&owner') and
    table_name = upper ('&&table_name')
    union
    select 'z', 0, ')'
    from dual
    order by 1, 2;
    spool off
    -- Cleanup
    clear column
    clear break
    clear compute
    undef owner
    undef table_name
    undef default_precision
    undef default_scale

  • Using SQL Loader script in a Stored Procedure

    Can I use SQL Loader script in a stored procedure and then execute it from a front-end appl.? The reason for this seemingly convoluted solution is that the users don't want a batch load though the records volume is quite high (around 1 mil). Other loads using ODBC connection or OLE DB seem to be inferior to SQL Loader.

    I would suggest a couple of solutions:
    1. Have a cgi script that can upload the file to the server from a web ui, then have the cgi script call the sql*loader file, and it will insert into the database.
    2. You can try to use External tables. This is avaliable in 9i and onwards. You will be able to make any sql DML on the external table.
    I would normally use sql*loader, move the data to a staging table with nologging, and paralle loading. After it has been loaded into the staging table I would process it into my main tables. Have used this approach with up to 60 million records in one load.
    You can do calls to C procedures, Pro*C procedures through PLSQL, as well as java calls, or use Java stored procedures.
    My experience is that SQL*Loader is the fastest way to load data into the database.

  • Sql loader script

    hi all i require a sql loader script
    i have some files that i will have to load to oracle database 11g... i dont know the number of files that will fall on the directory daily
    how do i do this. ?
    my requirement is in_file parameter in the control file should be dynamically populated with the file names and all the files should be processed ... the structure and columns in all the files are same.
    plz let me know if you have code for this.
    regards
    raj

    Raj,
    Here is you can use to generate sqlldr control and you can include this in simple sql script or call it from unix script or batch script. Run this sql from IDE or sqlplus and pass "table name " generate sqlldr control file
    spool &table_name..ctl
    SELECT      'LOAD DATA'
             || CHR (10)
             || 'INFILE '''
             || LOWER (table_name)
             || '.dat'''
             || CHR (10)
             || 'INTO TABLE '
             || table_name
             || CHR (10)
             || 'FIELDS TERMINATED BY '','''
             || CHR (10)
             || 'TRAILING NULLCOLS'
             || CHR (10)
             || '('
      FROM   user_tables
    WHERE   table_name = UPPER ('&table_name');
      SELECT   DECODE (ROWNUM, 1, '   ', ' , ') || RPAD (column_name, 33, ' ')
               || DECODE (
                     data_type,
                     'VARCHAR2',
                     'CHAR NULLIF (' || column_name || '=BLANKS)',
                     'FLOAT',
                     'DECIMAL EXTERNAL NULLIF(' || column_name || '=BLANKS)',
                     'NUMBER',
                     DECODE (
                        data_precision,
                        0,
                        'INTEGER EXTERNAL NULLIF (' || column_name || '=BLANKS)',
                        DECODE (
                           data_scale,
                           0,
                           'INTEGER EXTERNAL NULLIF (' || column_name || '=BLANKS)',
                           'DECIMAL EXTERNAL NULLIF (' || column_name || '=BLANKS)'
                     'DATE',
                     'DATE "&dformat" NULLIF (' || column_name || '=BLANKS)',
                     NULL
        FROM   user_tab_columns
       WHERE   table_name = UPPER ('&table_name')
    ORDER BY   column_id;
    SELECT   ')' FROM DUAL;
    spool offhttp://www.oracleutilities.com/OSUtil/sqlldr.html
    Regards

  • To schedule the SQL loader Script

    How to schedule the SQL loader Script everyday at 6.30PM in windows Server 2003?
    Could you please help me for this query?

    create a text file with your sql loader commands.
    from batch file you can run sqlplus and call this text file.
    add the schedule to your windows server

  • Script for sql*loader

    Hi All,
    I am loading the data from .csv format to table by using sql*loader.
    This sql*loader command was existed in one of the pl/sql Procedure. this procedure will first create a table and then it will get the data by using sql*loader command,then one procedure will run.
    to run this script we are manually loading the data from excel by using sql*laoder by running the .ctl command from Command prompt.. instead of doing manually this process is there any other way to do it automatically.
    if it is possible please let me know.
    here i am giving the script
    drop table emp;
    create table emp
    (eno number,
    ename  varchar2(20),
    job varchar2(20),
    sal number(4),
    doj date
    - here table created.then here by using below sql*loader command loading the data info emp table
    load data
    infile <file path>
    fields terminated by ','
    intto table emp
    (eno,
    ename,
    job,
    sal)by running this control file manually from command prompt loading the data.
    then there is a procedure which we need to to update the EMP table.
    for this whole thing we are just running the script except loading the data part.
    for this please let me know the automation part.
    Thanks.

    Hi,
    Create a shell Script(Unix) or Windows batch Job to automate the entire process. The script will like below
    1.Connect SQLPLUS with the Createtable.SQL file (The Createtable.sql will have the create table script)
    2.invoke sql loader with the control file
    3.then again connect SQLPLUS with the executeproc.sql file (the executeproc.sql will have the execute command to execute the stored procedure)
    by this way your entire process can be in one script and automate by scheduling it in unix or windows.
    Thanks,
    Vijay
    Edited by: Vijayaraghavan Krishnan on Nov 27, 2012 4:48 PM

  • Creating SQL-Loader script for more than one table at a time

    Hi,
    I am using OMWB 2.0.2.0.0 with Oracle 8.1.7 and Sybase 11.9.
    It looks like I can create SQL-Loader scripts for all the tables
    or for one table at a time. If I want to create SQL-Loader
    scripts for 5-6 tables, I have to either create script for all
    the tables and then delete the unwanted tables or create the
    scripts for one table at a time and then merge them.
    Is there a simple way to create migration scripts for more than
    one but not all tables at a time?
    Thanks,
    Prashant Rane

    No there is no multi-select for creating SQL-Loader scripts.
    You can either create them separately or create them all and
    then discard the one you do not need.

  • How to Eliminate Special Character in SQL LOADER Script

    How to eliminate special character from SQL LOADER script file which suppose not to insert in TABLE
    example.CSV lile like this
    <ABC/ , 7747>
    <DEF/ , 7763>
    <NEW/ , 7779>
    <OLD/, 7795>
    I have to remove < > and / character at the time of loading into table. How It could be done. It is not possible to remove < , > , / character manually from CSV file

    On Unix/Linux that's very easy, on Windows... I don't know...
    $ cat myfile.csv
    <ABC/ , 7747>
    <DEF/ , 7763>
    <NEW/ , 7779>
    <OLD/, 7795>
    $ tr -d "\057\074\076" <myfile.csv >outfile.csv
    $ cat outfile.csv
    ABC , 7747
    DEF , 7763
    NEW , 7779
    OLD, 7795
    $

  • ORA-00936 error from SQL expression in SQL*Loader script

    I am getting the above error on the following line in my SQL*Loader script:
    DIA_CLM_RES_OID DECIMAL EXTERNAL
    "SELECT N_ORG_ENTY_ID FROM TESTG4.ORG_ENTITY
    WHERE N_USER_ID =
    (SELECT UNIQUE WSR_NT_ID FROM CONV_CLM_RESOURCE
    WHERE CLM_RES_OID = :DIA_CLM_RES_OID)",
    What I am basically trying to do is a 2-table lookup of a value:
    1. Find a row in table CONV_CLM_RESOURCE where the value in column CLM_RES_OID matches the value in the input file in field DIA_CLM_RES_OID.
    2. Take the value of field WSR_NT_ID from that row and use it to find a row in table TESTG4.ORG_ENTITY.
    3. Take the value of field WSR_NT_ID from that row and set it in the target table in field DIA_CLM_RES_OID.
    In other words, I am essentially trying to translate the input value by using two other tables to lookup the value to translate to. However, no matter how I arrange it, I keep getting the "ORA-00936: missing expression" error on this statement.
    Can anyone see what I am doing wrong, or perhaps suggest a better way of accomplishing a two-table translation of a value?
    Thanks!

    Still not sure why this doesn't work, but I was able to create and use a function to do this instead, which is probably a better approach anyway.

  • Help in calling sql loader and an oracle procedure in a script

    Hi Guru's
    please help me in writing an unix script which will call sql loader and also an oracle procedure..
    i wrote an script which is as follows.
    !/bin/sh
    clear
    #export ORACLE_SID='HOBS2'
    sqlldr USERID=load/ps94mfo16 CONTROL=test_nica.ctl LOG=test_nica.log
    retcode=`echo $?`
    case "$retcode" in
    0) echo "SQL*Loader execution successful" ;;
    1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
    2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
    3) echo "SQL*Loader execution encountered a fatal error" ;;
    *) echo "unknown return code";;
    esac
    sqlplus USERID=load/ps94mfo16 << EOF
    EXEC DO_TEST_SHELL_SCRIPT
    it is loading the data in to an oracle table
    but the procedure is not executed..
    any valuable suggestion is highly appriciated..
    Cheers

    multiple duplicate threads:
    to call an oracle procedure and sql loader in an unix script
    Re: Can some one help he sql loader issue.

Maybe you are looking for