Sql loader shell scripting

Hi All,
I need help on sql loader shell scripting basically since my input file is csv file will load into some target table say xx_90 along defining with control and data file. what where the data that goes into the bad file a segment of scripting that keep watching on badfile directory path if any bad file it finds it should move to a sperate database error table.
Plz any sqlloader shellscripting experts can provide me the solution for this. Its a very urgent code i need to deliver I need the sample code for this your help is highy appreciated
thanku
sahana

thanku..............when the load fails it moves to bad file script something like filewatcher it sees the data in the badfile and loads into the database error table........as i am basically businessobjects developer as for time being they have assinged me the task i did few manual loading on sql loader but i never have any experince on writing unix scripting i am quite worried to get this script done........
can i use the samecode for the failed bad records into seperate external table......
here i would change the path location and the rest goes as it isright............................i have the script for loading the datainto the targetsomething like this:
sqlldr userid=ops$NGPTQMS/[email protected] \
control=${evncpaq1/apps/cp/cm/r11.5.10/geae/gl/include/PAY0001_test.ctl} \
data=${evncpaq1/data/infile/mon_gross_det.dat} \
log=${evncpaq1/data/infile/mon_gross_det.log} \
discard=${evncpaq1/data/infile/mon_gross_det.dis} \
errors=999
#bad=${BAD_FILE} \
if [ $? -ne 0 ]; then
echo "Error ! The sql loader call failed "
exit 1
fi
IF any error is there in the script plz modify it and plz provide the complete code where to incorporate the code which you have written for bad file. Would be set it in seqence the steps so that i can run it in cron tab basically i have no other support for me to assist me on the job.......
my dba has sent me the mail something like this:
Please see the attached script to archive the source file once we are done with loading the data to the database. You already have the script for loading the data to the database. Please incorporate the attached script with your loading script. This script is generic and can be used to archive the bad file also once it has been loaded into the database (in case of any failures). This script send an email in case of any failures to the defined email distribution list. Right now the assumption is to run this through the cron. It we need to run this through the Appworx I will have to do some changes in the script. Also we will have to install the appworx agent on the server. Please let me if we need to need to run this through appworx I will create the appworx module for the same.
and the archive script he sent is:
. $HOME/.profile
# Script to Archive SysLog files
# This script accepts 2 parameters
# - 1: Script Name          2: File Name
# Created By : Pravin Darbare
# Creation Date : 03/19/2008
# Modified Date :
# Modification History :
echo "Starting SysLog_archiving Process"
# Set Environmental Variables
echo "Invoke Set Variable Script `date '+%H%M%S'`"
# Set Local Script Variables
#SCRIPT_NAME=$1
SOURCE_DIR=$1
FILE_NAME=$2
# Zipping and Archive Source File
echo "Zip Source file `date '+%H%M%S'`"
#cp $LOAD_SRC_FILES/$SOURCE_DIR/$FILE_NAME $LOAD_SRC_FILES/syslog/Old_$FILE_NAME
gzip /$SOURCE_DIR/$FILE_NAME
check_rtn_status=$?
if [ $check_rtn_status != 0 ]; then
echo "Zipping source file Syslog process unsuccessfull"
mailx -s "Zipping source file during Syslog unsuccessfull" $PR_PAGER_EMAIL_LIST </dev/null
exit 1
fi
echo "Archive Source File `date '+%H%M%S'`"
mv /$SOURCE_DIR/$FILE_NAME.gz /$SOURCE_DIR/archive/$FILE_NAME.gz$FILE_EXT
check_rtn_status=$?
if [ $check_rtn_status != 0 ]; then
echo "Archiving source file during Syslog load process unsuccessfull"
mailx -s "Archiving source file during Syslog load process unsuccessfull" $PR_PAGER_EMAIL_LIST </dev/null
exit 1
fi
# example of calling file Syslog_archiving_Files.sh /apps/syslog/source_dir a.txt
# example of calling file (Bad file) Syslog_archiving_Files.sh /apps/syslog/source_dir_bad a.txt
# You need to have directory "archive" in both pathes .
based on the complete detailed mail must having some view plz provide me something like exact code the rest path directories i will change it........
for me its highly urgent to keep up my job
Your support is highly appreciated
Thanks&Regards
sahana

Similar Messages

  • Loading incomplete using sqlplus_exec_template.sql  in shell script

    Hi,
    I've tried to automate the dataloading by calling sqlplus_exec_template.sql for each mapping in the shell script bash. (I comment out the last exit line in the script). But the loading were always partially complete for those that take longer time, says more than 5 or 10min. I've also tried to call each mapping in different shell and got the same result. How do you work around this? Below is part of the lines in my shell script. Thanks.
    sqlplus -s test_rta/test_rta << EOF
    @sqlplus_exec_template.sql 'TEST_RTR' 'TEST_LOC' 'PLSQL' 'CONSOL_SUP_MAP' ',' ','
    @sqlplus_exec_template.sql 'TEST_RTR' 'TEST_LOC' 'PLSQL' 'CONSOL_PART_MAP' ',' ','
    EOF

    I 've tried to use :
    sqlplus username/[email protected] @C:\OWB\owb\rtp\sql\sqlplus_exec_template.sql
    rtschema OWBLOCATION SQL_LOADER CRD_APPL_MAPPING "," ","
    where OWBLOCATION I have used the deploy location of the mapping for my case, created within OWB. The value is CCS_DEPLOY.
    But the error is the same :
    ======================================================
    Stage 1: Decoding Parameters
    | location_name=CCS_DEPLOY
    | task_type=SQL_LOADER
    | task_name=CRD_APPL_MAPPING
    Stage 2: Opening Task
    declare
    ERROR at line 1:
    ORA-20001: Task not found - Please check the Task Type, Name and Location are
    correct.
    ORA-06512: at line 261
    ========================================================
    could you tell me the SQL used by WB_RT_API to get the task from runtime schema. So that I could check the correct location myself.
    Or how could I view the pl/sql of WB_RT_API_EXEC which is wrapped.
    Thx for your help.
    Rg.
    CH

  • Embed SQL in shell script

    I'm trying to embed sql statements in shell.
    I'm new to this..
    Can someone please pass some relevant document links on the web which demonstrates it?
    What I'm looking for is:
    1) How to pass variables from shell environment to sql
    2) How to pass values back to the shell from sql
    Example:
    Say, I want to run a concurrent request ( inside a shell script) . Then I want to check the status of this concurrent requests from FND_CONCURRENT_REQUESTS
    For which I have do a:
    #/bin/bash
    #Submit the request
    CONCSUB APPS/APPS SYSADMIN 'System Administrator' SYSADMIN CONCURRENT FND FNDSCURS >> /tmp/${TWO_TASK}request.log
    #Here, I pull out the value of request id from the log #in v_request_no
    v_request_no=`cat /tmp/${TWO_TASK}request.log | cut -d" " -f3`
    echo "Submitted request No: ${v_request_no}"
    Now, I want to check the status of this request, for which I want to embed the sql:
    select status_code from FND_CONCURRENT_REQUESTS where request_id=${v_request_id}
    How do I embed this?
    And later, I want to pass the value of "status_code" back to my shell and do some manipulation.
    How do I get the value ( of status_code) back in shell script?
    I did a quick hunt on the google to find a relevant doc. No luck yet, so I thought I'll post it here and then go back to some more hunting.
    Message was edited by:
    itzz.me

    Replying to myself instead of editing previous post. Confusing either way, hopefully I picked the less-confusing route.
    The second script snippet that I posted would work really well except for one tiny detail: exit codes have to be numeric. The status_code column in FND_CONCURRENT_REQUESTS is certainly not numeric. :-)
    Here's something that should work. I even checked it for syntax this time, because, well, it's really ugly. :-) Needless to say, you'll need to modify it slightly to plug into your script, since I hard-coded a requestid for purposes of illustration. Please note that the sqlplus command in the here document is enclosed in backticks, not single quotes:
    ----begin code snippet---
    #!/bin/bash
    v_request_id=2415616 #Just an example, sub your own value here
    status_code=`sqlplus -s apps/appspass<<EOF | grep Code | cut -f2 -d:
    select 'Code:' || status_code
    from fnd_concurrent_requests
    where request_id = $v_request_id;
    exit;
    EOF`
    echo "Status code is: $status_code"
    ----end code snippet-------
    If you can't pass in the apps password from the environment, and have to hard-code a password into the script (yecccchhh), I'd suggest setting up a read-only user with SELECT privileges on FND_CONCURRENT_REQUESTS, and running sqlplus as the read-only user instead of apps.

  • PL/SQL using Shell Script

    Hi,
    I want to study in details about how to use shell script in pl/sql codes. Can any one suggest some useful link on the same.
    Nordik

    smon wrote:
    BluShadow wrote:
    miriam_omaha wrote:
    If you mean execute a shell script from a procedure, there are ways, not easy ways, to execute a shell script - try this thread on that topic:Not easy?
    What's not easy about setting up a job using DBMS_SCHEDULER which can directly call any executable at the operating system level?that doesn't meet the requirement, it's about executing host commands from within plsql.Which you can do with DBMS_SCHEDULER by creating a job to execute straight away. DBMS_SCHEDULER can execute operating system commands...
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#i1010013
    >
    'EXECUTABLE'
    This specifies that the program is external to the database. External programs implies anything that can be executed from the operating system's command line. AnyData arguments are not supported with job or program type EXECUTABLE.

  • Passing variable from sql to shell script

    Usually we can pass arguments from shell script to the sql that us called inside the shell script. But I also want to do the reverse. I have the location of my backup path in a table. I want to run the rman script (shell), read this parameter from the table and use this to construct the "format" path in rman. Anyone has any ideas about this. Thanks.

    To achieve getting the modified value from the table everytime the job runs, I encapsulated this in another job.
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB(
    JOB_NAME           => 'TEST_LOGS_MAIN',
    JOB_TYPE             => 'PLSQL_BLOCK',
    JOB_ACTION          => 'declare
    v_aname varchar2(32);
    begin
    select aname into v_aname from attr where attrid = 3;
    DBMS_SCHEDULER.CREATE_JOB(
    JOB_NAME        => ''TEST_LOGS'',
    JOB_TYPE        => ''EXECUTABLE'',
    JOB_ACTION      => ''/opt/sql/testy.sh'',
    number_of_arguments => 1,
    COMMENTS        => ''TEST'');
    dbms_scheduler.set_job_argument_value(''TEST_LOGS'',1,v_aname);
    dbms_scheduler.enable(''TEST_LOGS'');
    end;',
    REPEAT_INTERVAL => 'FREQ=MINUTELY',
    ENABLED           => TRUE);
    END;
    /

  • Calling sql through shell script

    How do i call a sql file through shell script in unix ?

    Rahul India wrote:
    export ORACLE_HOME=$ORACLE_BASE/product/10g
    cd $ORACLE_HOME
    set `sqlplus -s <SCHEMA_NAME>/<SCHEMA_PASSWORD> <<EOF
    @r_100.sql
    exit;   
    EOF`THIS SCRIPT IS OK?You'll also need to set ORACLE_SID
    And I don't know why everyone is putting the reference to sqlplus inside a "set" valuation, nor why they are putting the reference to the script in a redirected input stream. All you need is
    sqlplus -s user/password  @r_100.sqlAnd to insure the invironment is correctly set:
    export ORACLE_SID=whatever
    export ORAENV_ASK=NO
    . oraenv
    unset ORAENV_ASK=NO
    sqlplus -s user/password  @r_100.sql

  • Capturing Users with running sql in shell script after every 10min

    Hi All,
    we have a strange prob. of database crash, therefore decided to check what users do when OS/DB crashes,
    i need your input in RUNNING/SCHEDULING such a script which gathers all active users with running SQL and append in a logfile so that we are aware of what happened when DB/OS Crashed.
    i can run this run a query from V$SESSION,V$SQL, and V$PROCESS but i need your input writing such a SHELL Script and scheduling can run by CRON.
    Regards.

    Here ya go.
    (Assuming you want a script to run against one sid)
    script:
    #!/bin/ksh
    # Set environment
    . $HOME/.profile
    export ORACLE_SID=your sid
    sqlplus <<! > /some_report_file
    / as sysdba
    sql you want to execute here*
    exit
    cron entry:
    0,5,10,15,20,25,30,35,40,45,50,55 * * * * /your/script/name/here > /dev/null 2>&1

  • Calling a sql in shell script

    Dear All,
    I want to call an sql script within a unix shell script. I want to pass a parameter into the shell script which should be used as a parameter in teh sql script.
    e.g
    $ ./shell1.sh 5000129
    here 5000129 is a prameter
    inside shell script i am calling one sql script
    e.g.
    @script1.sql;
    inside the sql script I have an update statement
    UPDATE abc set xx = 22 where id = 500129;
    as you can see the 5000129 passed as shell script parameter, is being passed as parameter in the sql script.
    Please can you advise how can I achieve this?
    Many Thanks,

    Hi
    You could try something like this.
    tmpSQLFile=$EXTLOG_DIR/tmpSQLFile_$$.sql
    tmpSpoolFile=$EXTLOG_DIR/tmpSpoolFile_$$.sql
    export ORACLE_PWD=`cat /home/oracle/secure/runtime_user.dat`
    echo "spool $_tmpSpoolFile" > $_tmpSQLFile
    echo "SET ECHO OFF NEWP 0 SPA 0 PAGES 0 FEED OFF HEAD OFF TRIMS ON LINESIZE 10000 TIMING OFF" >> $_tmpSQLFile
    echo "begin" >> $_tmpSQLFile
    echo "DW_MGT_SCHEMA.PKG_RUNTIME_HANDLER.SP_UPD_RUNTIME_EXT_CTL_LOG_TDT(p_transfer_date => '$today', p_schedule_id => $schedule_id);" >> $_tmpSQLFile
    echo "end;" >> $_tmpSQLFile
    echo "/" >> $_tmpSQLFile
    echo "exit" >> $_tmpSQLFile
    sqlplus ${ORACLE_USER}@${ORACLE_SID} @$_tmpSQLFile << EOT
    `echo $ORACLE_PWD`
    EOTCheers
    Gary

  • Need to call Shell script that uses SQL loader in APex4.1/11g

    Hi there!
    I have a requirement, wherein I have to call a shell script that connects to an external server, ftp's a file in and then uses sqlloader to load data into our table. Now we have the ftp script that does this for another program, but is a scheduled job. I wanted to call the ftp shell script from within APEX. Any suggestions on how this can be done, what PL/SQL logic can we use? I see online some people using dbms scheduler for this?
    Thank you
    Sun

    Hi,
    Create some sh script on your oracle host machine where you can join into external server and run the process.
    something like:
    run_external_sh.sh
    #!/bin/sh
    ssh ext_user@ext_host ./sqlloader/import/import.shThen create a external JOB to call it via ORACLE(PL/SQL)
    -- Call Shell Script.
    BEGIN
      DBMS_SCHEDULER.create_program (
        program_name        => 'external_call_sh',
        program_type        => 'EXECUTABLE',
        program_action      => '/local_host/call_external/sh/run_external_sh.sh',
        number_of_arguments => 0,
        enabled             => TRUE,
        comments            => 'Call external SH script');
    END;
    /Now you can create a scheduled/or not scheduled JOB
    -- Job defined by an existing program and schedule.
    BEGIN
      DBMS_SCHEDULER.create_job (
        job_name      => 'jb_external_call_sh',
        program_name  => 'external_call_sh',
        schedule_name => 'external_call_scheduler', -- created scheduler
        enabled       => TRUE,
        comments      => 'Job defined by an existing external_call_sh program and schedule.');
    END;
    /Now you can call the JOB in APEX in PL/SQL process.
    BEGIN
      -- Run job synchronously.
      DBMS_SCHEDULER.run_job (job_name            => 'jb_external_call_sh');
    END;Regards
    J :D

  • Passing shell script variable to sql file by reference (bind variable)

    Hi All,
    I need to import around 50 files every 15 minutes into my target table.
    I am using shell script and call procedure to do transform.
    I used crontab to do this automate task.
    Here is my shell script and sql file:
    shell script:
    #!/bin/sh
    export ORACLE_HOME=/u01/app/oracle/product/9.2.0.4.0
    export PATH=$ORACLE_HOME/bin
    find /path_rawfile/rawfile -iname raw\*.in > myfile.lst
    nfile=1
    while [ true ]
    do
    read iFile #read a line
    if [ $? -ne 0 ] #Break if EOF
    then
    break
    fi
    #$PATH/sqlplus -s /NOLOG @load_raw.sql $iFile
    #/bin/mv -f $iFile /path_rawfile/rawfile/done/
    done < myfile.lst
    sql file:
    connect test/test@evn1
    set serveroutput on
    variable filename varchar2(50)
    begin
    :filename := '&1';
    exec my_tranform(:filename);
    dbms_output.put_line(:filename);
    end;
    exit;
    Even I used bind variable pass to procedure my_transform...
    But when i query in sys.v_$sqlarea, the :filename:='&1' still hard parse to sqlarea.
    One filename one statement and keep increasing ..
    Could everyone help me to change it to bind varialbe(soft parse)?
    I would like to incresae my database performance.
    Thanks in advance.
    Cheer
    Message was edited by:
    lux

    It is the procedure.
    It's my fault.
    Here is my SQL file again:
    conn test/test@evn1
    variable filename varchar2(500);
    exec :filename:='&1';
    exec my_transform(:filename);
    exit;
    I call this sql file from shell script and call in loop due to i need to load all file one time.
    Once i use <<EOF it raise error that's why when I deleted it.
    Anyway, what I need to do here is to use bind variable (soft parse).
    Since I need to load around 50 files every 15 minutes.
    exec :filename:='&1'; this statmet have found hard parse in v_$sqlarea.
    I would like to change this to bind varialbe.
    Thanks again for your help.

  • Pls give some shell scripting for sql/plsql

    pls give some shell scripting for sql/plsql

    794244 wrote:
    pls give some shell scripting for sql/plsqlNeither SQL or PL/SQL are shell script languages. Both are server side languages that executes inside an Oracle database server process.
    This is an important concept to understand when using SQL*Plus for example to "script" interaction with an Oracle database.

  • 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 by using shell script, not able to insert data

    Hi,
    I am trying to dump the data by using shell script.(in shell script i am having sqlldr command)(its a host excutable method cocurrent program)
    When i am loading the data, by placing my files(.ctl,.prog,.csv,symbolink file for .prog) in $Custom_top/bin, it is loading exactly. 17000 records inserted.
    But if i am loading the data by placing my files in $custom_top/custom_folders. unable to insert total data. only 43 records inserting.
    Please any one can help me.
    Thanks in advance.
    Rama.

    Srini, Thanks a lot for ur reply,
    Oracle Apps version R12,
    Microsoft windows XP profissional
    Version 2002 service Pack 3
    My Control file Script is:
    load data
    infile '$XADP_TOP/data/CPIU/in/XXOKS_Price_Increase.csv'
    append
    into table XXOKS_CONTRACT_PRICE_INCR_DTLS
    fields terminated BY ',' optionally enclosed by '"'
    TRAILING NULLCOLS
    (EXCLUSION_FLAG,
    LEGACY_NUMBER,
    CUSTOMER_NUMBER,
    CUSTOMER_NAME,
    REQUEST_ID,
    CONTRACT_NUMBER,
    CONTRACT_START_DATE,
    CONTRACT_END,
    REQUEST_LINE_ID,
    LINE_START_DATE,
    LINE_END_DATE,
    ITEM_NUMBER,
    ITEM_DESCRIPTION,
    UNIT_PRICE,
    QTY,
    NEW_UNIT_PRICE,
    LINE_AMOUNT,
    NEW_LINE_AMOUNT,
    PRICE_INCREASED_DATE,
    PERCENTAGE_INCREASED,
    ORIGINAL_CONTRACT_AMOUNT,
    NEW_CONTRACT_AMOUNT,
    PRICE_INCREASE_AMOUNT)
    My .prog File is: Please fidn that i created symbolink file also for my .prog.
    if [ -z $XADP_TOP ];then
    echo "XADP_TOP environment variable is not set!"
    exit 1
    fi
    cd $XADP_TOP/data/CPIU/in
    DATE=`date +%y%m%d:%H%M`
    i_program_name="$0"
    i_ora_pwd="$1"
    i_user_id="$2"
    i_user_name="$3"
    i_request_id="$4"
    i_ftp_host_name="$5"
    i_ftp_user_name="$6"
    i_ftp_user_password="$7"
    ftp_prog() {
    # FTP Function to reuse the FTP Commands
    if [ $# -ne 6 ];then
    echo "Usage : ftp_prog <Hostname> <User name> <Password> <Remote Directory> <command> <filename>"
    exit 2
    fi
    l_ftp_host_name="$1"
    l_ftp_user_name="$2"
    l_ftp_user_password="$3"
    l_ftpdir="$4"
    l_ftp_command="$5"
    l_ftp_filename="$6"
    ftp -v -n ${l_ftp_host_name} <<EOF
    user ${l_ftp_user_name} ${l_ftp_user_password}
    ascii
    cd ${l_ftpdir}
    ${l_ftp_command} ${l_ftp_filename}
    quit
    EOF
    #exit $?
    # setting the ftp directory
    #ftpdir="/`echo ${TWO_TASK:-$ORACLE_SID}|tr "[A-Z]" "[a-z]"`/CPIU"
    ##ftpdir="/FinTEST/quoting/PS/ar"
    ftpdir="$XADP_TOP/data/CPIU/in"
    # setting the in directory and out directory
    indir="$XADP_TOP/data/CPIU/in"
    outdir="$XADP_TOP/data/CPIU/out"
    ftp_prog ${i_ftp_host_name} ${i_ftp_user_name} ${i_ftp_user_password} ${ftpdir} get XXOKS_Price_Increase.csv
    echo $ftpdir
    echo "Converting the data file into unix mode"
    dos2unix XXOKS_Price_Increase.csv XXOKS_Price_Increase.csv
    chmod 777 XXOKS_Price_Increase.csv
    cd $XADP_TOP/bin
    echo "Trying to excute sqlldr and entering into the into control file"
    $ORACLE_HOME/bin/sqlldr userid=$i_ora_pwd control=XXOKS_PRICE_INCR_LOAD log=$XADP_TOP/log/XXOKS_PRICE_INCR_LOAD_${DATE}.log;
    exit_status=$?
    echo "Checking the status and giving permissions to the data file which in in dir"
    if [ $exit_status -eq 0 ]; then
    cd $XADP_TOP/data/CPIU/in
         chmod 777 XXOKS_Price_Increase.csv
    echo "try to move data file into out dir"
    # Moving the file to out directory
    mv XXOKS_Price_Increase.csv ${outdir}/XXOKS_Price_Increase.csv_${DATE}
    #echo "ready to zip file in out dir step6"
    # Zipping the file
    #gzip -f ${outdir}/XXOKS_Price_Increase.csv_${DATE}
    echo "deleting the file which is in dir"
    # Deleting the file from in directory
    /bin/rm -f ${indir}/XXOKS_Price_Increase.csv
    # Deleting from the remote directory
    ftp_prog ${i_ftp_host_name} ${i_ftp_user_name} ${i_ftp_user_password} ${ftpdir} delete XXOKS_Price_Increase.csv
    echo "sqlloader finished successfully."
    else
    echo "Error in loader"
    ##echo "Loader error in Price Increase Detials File ${i_file}"
    fi
    exit $exit_status
    And My Log file Comments are
    SQL*Loader: Release 10.1.0.5.0 - Production on Thu Dec 3 01:32:08 2009
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Control File: XXOKS_PRICE_INCR_LOAD.ctl
    Data File: /oesapp/applmgr/GIS11/apps/apps_st/appl/xadp/12.0.0/data/CPIU/in/XXOKS_Price_Increase.csv
    Bad File: XXOKS_Price_Increase.bad
    Discard File: none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array: 64 rows, maximum of 256000 bytes
    Continuation: none specified
    Path used: Conventional
    Table XXOKS_CONTRACT_PRICE_INCR_DTLS, loaded from every logical record.
    Insert option in effect for this table: APPEND
    TRAILING NULLCOLS option in effect
    Column Name Position Len Term Encl Datatype
    EXCLUSION_FLAG FIRST * , O(") CHARACTER
    LEGACY_NUMBER NEXT * , O(") CHARACTER
    CUSTOMER_NUMBER NEXT * , O(") CHARACTER
    CUSTOMER_NAME NEXT * , O(") CHARACTER
    REQUEST_ID NEXT * , O(") CHARACTER
    CONTRACT_NUMBER NEXT * , O(") CHARACTER
    CONTRACT_START_DATE NEXT * , O(") CHARACTER
    CONTRACT_END NEXT * , O(") CHARACTER
    REQUEST_LINE_ID NEXT * , O(") CHARACTER
    LINE_START_DATE NEXT * , O(") CHARACTER
    LINE_END_DATE NEXT * , O(") CHARACTER
    ITEM_NUMBER NEXT * , O(") CHARACTER
    ITEM_DESCRIPTION NEXT * , O(") CHARACTER
    UNIT_PRICE NEXT * , O(") CHARACTER
    QTY NEXT * , O(") CHARACTER
    NEW_UNIT_PRICE NEXT * , O(") CHARACTER
    LINE_AMOUNT NEXT * , O(") CHARACTER
    NEW_LINE_AMOUNT NEXT * , O(") CHARACTER
    PRICE_INCREASED_DATE NEXT * , O(") CHARACTER
    PERCENTAGE_INCREASED NEXT * , O(") CHARACTER
    ORIGINAL_CONTRACT_AMOUNT NEXT * , O(") CHARACTER
    NEW_CONTRACT_AMOUNT NEXT * , O(") CHARACTER
    PRICE_INCREASE_AMOUNT NEXT * , O(") CHARACTER
    value used for ROWS parameter changed from 64 to 43
    Table XXOKS_CONTRACT_PRICE_INCR_DTLS:
    43 Rows successfully loaded.
    0 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Space allocated for bind array: 255162 bytes(43 rows)
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records read: 43
    Total logical records rejected: 0
    Total logical records discarded: 0
    Run began on Thu Dec 03 01:32:08 2009
    Run ended on Thu Dec 03 01:32:08 2009
    Elapsed time was: 00:00:00.19
    CPU time was: 00:00:00.04
    Plz srini help me.
    Thanks in advance
    Rama..

  • 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 ~]$

  • Looping through SQL statements in shell script

    Hello members,
    I'm working on the Solaris environment and the DB i'm using is Oracle 10g. Skeleton of what I'm attempting;
    Write a ksh script to perform the following. I have no idea how to include my sql query within a shell script and loop through the statements. Have therefore given a jist of what I'm attempting, below.
    1. Copy file to be processed (one file at a time, from a list of 10 files in the folder ).
    for i in *
               do
               cp $i /home/temp[/CODE]2 . Create a snapshot(n) table : Initialize n = 1 -- -- To create my snapshot table and inserts records in SQL
    create table test insert account_no, balance from records_all;3. Checking if the table has been created successfully:
    select count(*) from snapshot1 -- query out the number of records in the table -- always fixed, say at 400000
    if( select count(*) from snapshot(n) = 400000 )
    echo " table creation successful.. proceed to the next step "
    else
    echo " problem creating table, exiting the script .. "  4. If table creation is successful,
    echo " select max(value) from results_all " -- printing the max value to console
    5. Process my files using the following jobs:
    ./runscript.ksh - READ -i $m ( m - initial value 001 )
    ./runscript.ksh - WRITE -i $m ( m - initial value 001 -- same as READ process_id )
    -- increment m by 1
    6. Wait for success log
    tail -f log($m)* | -egrep "^SUCCESS"7. looping to step1 to :
    Copy file 2 to temp folder;
    create snapshot(n+1) table
    Exit when all the files have been copied for processing.
    done -- End of Step 1
    Pointers on getting me moving will be very valuable.
    thanks,
    Kris

    Hi,
    Are you inserting the data from file or from some table.
    If it is from file, I suggest sql loader would be better, I suppose.
    If it is from table, then something like this
    for i in *
               do
    sqlplus username/password@db_name<<EOF
                create table test select * account_no, balance from records_all;
    EOF
    exit
    doneAnurag

Maybe you are looking for