Calling SQL statements from Shell scripts

Hi,
I want to call external package procedures, declare some variables & do some oracle validations in the shell script.
How SQL environment is set in shell script & is this one time process or I have to write few statements before every SQL statement.
Please explain with an example.
Thanks..

is this one time process Yes. Example :
$ cat script.sh
export ORACLE_HOME=/home/oracle/base/OraHome10
export ORACLE_SID=db102
export PATH=$ORACLE_HOME/bin:$PATH
sqlplus -s / as sysdba << EOF
select to_char(sysdate,'dd/mm/yyyy hh24:mi:ss') date_time
from dual;
exit
EOF
sqlplus -s / as sysdba << EOF
col global_name for a60
select * from global_name;
exit
EOF
$ ./script.sh
DATE_TIME
27/02/2008 11:11:27
GLOBAL_NAME
DB102
$

Similar Messages

  • Calling SQL statement from a script problem

    Hello,
    I have a script e.g query.sh:
    #!/bin/sh
    sqlplus -s ${ORACLE_USER} << HIC
    set heading off
    set newpage none
    SELECT 'ALTER TABLE '||'TEST_TABLE'||' ADD PARTITION '||' P'|| TO_CHAR(TRUNC(sysdate+7), 'IYYY')||'W'|| TO_CHAR(TRUNC(sysdate+7), 'IW')||' VALUES LESS THAN(TO_DATE('''|| TO_CHAR(sysdate + 14, 'YYYYMMDD')||''',''YYYYMMDD''));' FROM DUAL;
    exit
    HIC
    This will actually give me: ALTER TABLE TEST_TABLE ADD PARTITION P2010W46 VALUES LESS THAN(TO_DATE('20101122','yyyymmdd'));
    I am executing this output from the second script. e.g create_part.sh
    #!/bin/sh
    SQL=`/home/bill/scripts/query.sh`
    sqlplus ${ORACLE_USER} << EOF
    set serveroutput on size 1000000
    set heading off
    $SQL
    exit
    EOF
    When I am running the 2nd script I am getting:
    SQL> SQL> SQL> SQL> 2 ALTER TABLE test_table ADD PARTITION P2010W46 VALUES LESS THAN(TO_DATE('20101122','yyy
    ERROR at line 1:
    ORA-01861: literal does not match format string
    I suspect that the output from the 1st script wraps to a second line, and it failes to execute properly.
    Oracle is 9i
    Please suggest a way to overcome this problem.
    Thank you in advance.

    If you are not passing in any variable values that you need the shell to substitute intot he source then placing the SQL into a separate .sql file and then just using start scriptname from the shell can simplify the code especially if any shell script meta-characters like '$' appear in the SQL. Otherwise you have to escape the meta-characters.
    sqlplus /nolog <<EOF
    start script_name
    exit
    EOF
    It is also possible to write the sqlplus script to accept substitution variable from the caller so the line above would look like start script_name $var1 $var2
    HTH -- Mark D Powell --

  • How To Execute SQL Statements From Shell Scripts?

    I need to extecute some SELECT statements from a shell scripts. Could anybody kindly tell me how to do that, or which document i should refer to ? Thank you very much!

    You can execute SQLPlus with the SQL in a file (sqlplus -s @<sql-script>).

  • 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

  • Unable to see the sql serveroutput from shell script

    Hello experts,
    I have a shell script which I am using to call a pl/sql proc.
    This proc writes to dbms_output.
    I would like to capture the dbms_output to a file when calling sqlplus from my shell script.
    Here is the code:
    ===============================
    echo "
    sqlplus apps/$APPS_PWD << ENDOFSQL
    set serveroutput ON
    set feedback off
    set verify off
    set linesize 250
    set pagesize 250
    begin
    jdr_utils.listcustomizations('$i');
    end;
    exit
    ENDOFSQL
    " >> new.log
    ===============================
    What I get in the 'new.log' is given below:
    ===============================
    sqlplus apps/prj08app << ENDOFSQL
    set serveroutput ON
    set feedback off
    set verify off
    set linesize 250
    set pagesize 250
    begin
    jdr_utils.listcustomizations('/oracle/apps/irc/candidateSelfService/webui/VisVacDispPG');
    end;
    exit
    ===============================
    ENDOFSQL
    What I would like to get is the dbms_output given by the procedure.
    Please suggest.
    Thanks,
    Vinod

    Vinod wrote:
    Hello experts,
    I have a shell script which I am using to call a pl/sql proc.
    This proc writes to dbms_output.
    I would like to capture the dbms_output to a file when calling sqlplus from my shell script.
    Here is the code:
    ===============================
    echo "
    sqlplus apps/$APPS_PWD << ENDOFSQL
    set serveroutput ON
    set feedback off
    set verify off
    set linesize 250
    set pagesize 250
    begin
    jdr_utils.listcustomizations('$i');
    end;
    exit
    ENDOFSQL
    " >> new.log
    ===============================
    What I get in the 'new.log' is given below:
    ===============================
    sqlplus apps/prj08app << ENDOFSQL
    set serveroutput ON
    set feedback off
    set verify off
    set linesize 250
    set pagesize 250
    begin
    jdr_utils.listcustomizations('/oracle/apps/irc/candidateSelfService/webui/VisVacDispPG');
    end;
    exit
    ===============================
    ENDOFSQL
    What I would like to get is the dbms_output given by the procedure.
    Please suggest.
    Thanks,
    VinodYou need to realize & understand that EVERY command line command runs in its own separate OS process.
    So the results from DBMS_OUTPUT get sent to Standard Out for the sqlplus process; which is NOT attached to your terminal.
    The bottom line is you can't get there from here.

  • Call sql statement from JComboBox component

    Hi there,
    I Have created a frame to populate two JComboBoxs, I'm populating the first one from a database using SQL, this datable is showing the category to below every report.
    anybody know how can I select from my first JComboBox a record a call a second SQL statement acutomatic, the idea is populate me second JCombox with data like my first one, remember the first one is a header

    With a JComboBox you have to be careful that you don't run a query when just the cursor is moved up or down the list. If you want the listener to fire just when enter is pressed or the mouse is clicked, then do this:
    //This stops events being fired when the cursor is used on the list
    comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);You should also attach an event listener like this one:
    comboBox.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent evt) {
                            executeSomeQuery(comboBox.getSelectedItem().toString());               }
              });Or something similar to above, have a play around with it and it should work how you want it to.
    Message was edited by:
    JStudent911

  • How to call a procedure from  Shell Script

    Friends,
    How can i call a procedure from a shell script ? If any one know the answer , let me know immediately .
    Thanks in advance .
    Chakks

    We connect using SQLPlus commands on the Unix server:-
    Our code block is below:- We've got DBMS_OUTPUT in the procedure, hence the spooling. You don't need all this, but you do need the sqlplus directory, etc... in your profile.
    sqlplus -s <<EOF > ${CREATE_LOG_FLE}
    $UserName/$Password@$SID
    SET SERVEROUTPUT ON SIZE 1000000;
    spool ${CREATE_LOG_FLE}
    EXECUTE $STORED_PROC(${Months}, ${DeleteRecords});
    EOF
    Hope that helps

  • How to Call pl/sql procedure from shell script

    Hi,
    I've one procedure which takes the xml file name as input from one of the remote location. Every day users keep one file in that location.
    For eg:
    ACS_RPO00020110316_20110316220956.xml
    ACS_RPO00020110319_20110319220956.xml
    I need to read the latest file in this case. In this case second one is the latest file.
    Can some body please help me how to write script to pass parameter to that procedure that via shell program and execute that.
    Thanks in advance.
    Regards
    Nagendra

    hi
    I executed the below mentioned steps, but I did not get any result:
    I am pasting all the steps which I did
    -bash-3.2$ ls -lrt
    total 316
    -rw-r--r-- 1 oratest dba 4884 Mar 16 03:56 XXGEBIZ_EPO160320110356.xml
    -rw-r--r-- 1 oratest dba 4884 Mar 16 03:57 XXGEBIZ_EPO160320110357.xml
    -rw-r--r-- 1 oratest dba 4884 Mar 16 17:52 GEBIZ_ACS_RPO00020110316_20110316175216.xml
    -rw-r--r-- 1 oratest dba 38 Mar 16 18:18 GEBIZ_ACS_RPO00020110316_20110316181858.NODATA
    -rw-r--r-- 1 oratest dba 63 Mar 16 22:09 GEBIZ_ACS_RPO00020110316_20110316220956.xml
    -rw-r--r-- 1 oratest dba 9716 Mar 16 22:14 GEBIZ_ACS_RPO00020110316_20110316221429.xml
    -rw-r--r-- 1 oratest dba 12988 Mar 17 01:42 GEBIZ_POC_RPO000EPO20110317_20110317014247.xml
    -rw-r--r-- 1 oratest dba 13103 Mar 17 01:53 GEBIZ_POC_RPO000EPO20110317_20110317015356.xml
    -rw-r--r-- 1 oratest dba 38 Mar 17 01:57 GEBIZ_POC_RPO00020110317_20110317015712.NODATA
    -rw-r--r-- 1 oratest dba 38 Mar 17 18:44 GEBIZ_ACS_RPO00020110317_20110317184423.NODATA
    -rw-r--r-- 1 oratest dba 12326 Mar 17 18:46 GEBIZ_ACS_RPO00020110317_20110317184603.xml
    -rw-r--r-- 1 oratest dba 67578 Mar 18 01:32 GEBIZ_POF_RPO000EPO20110318_20110318013232.xml
    -rw-r--r-- 1 oratest dba 14484 Mar 18 20:27 GEBIZ_POF_RPO000EPO20110318_20110318202754.xml
    -rw-r--r-- 1 oratest dba 47653 Mar 19 01:29 GEBIZ_PYS_RPO00020110319_20110319012953.xml
    -rw-r--r-- 1 oratest dba 937 Mar 21 09:34 GEBIZ_SUPP.xml
    -rw-r--r-- 1 oratest dba 947 Mar 21 09:35 GEBIZ_SUPP1.xml
    -rwxrwxrwx 1 oratest dba 121 Mar 21 17:43 test
    -bash-3.2$
    -bash-3.2$ cat > test
    ls -lrt | tail -1
    filelist = $(ls GEBIZ_SUPP*.xml)
    for file in $filelist ; do
    echo "inside loop"
    file = $file
    echo "file name " $file
    done
    XGBZ_SUPP_MAST_XMLTAG_PROC $file
    -bash-3.2$ chmod 777 test
    -bash-3.2$ ./test
    -bash: ./test: Text file busy
    -bash-3.2$
    Initially I listed down all the files, in a sample file I've written the steps. But nothing is executed.
    One thing I want to ask here XGBZ_SUPP_MAST_XMLTAG_PROC is my procedure. I think I need to invoke sqlplus in the so as to execute my pl/sql script.
    Gurus, please let me know how to write them.
    Regards
    Nagendra

  • Please help to call oracle procedure with out paramter from shell script

    Hi
    I want to call a process with out parameter from shell script. I am calling process in shell script in below way
    function Process_loads {
    ( echo 'set serveroutput on size 1000000 arraysize 1'
    echo "set pagesize 0 term on verify off feedback off echo off"
    echo "BEGIN"
    echo " dbms_output.put_line('Before Calling The package'); "
    echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
    echo " dbms_output.put_line('After Calling The package'); "
    echo "EXCEPTION "
    echo " WHEN OTHERS THEN "
    echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
    echo " ROLLBACK;"
    echo "END;"
    echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
    Here $error_code is out paramter. All varaibles passed in process are declared with export command.
    When executing .sh it gives below error
    "sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
    Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
    Thanks in advance

    You can try this:
    From sql*plus
    SQL> ed
      1  create or replace procedure my_proc(p_id in int, p_result out int)
      2  as
      3  begin
      4  select 10 * p_id
      5  into p_result
      6  from dual;
      7* end my_proc;
    SQL> /
    Procedure created.
    SQL> set serveroutput on
    SQL> declare
      2  v_r int;
      3  begin
      4  my_proc(10,v_r);
      5  dbms_output.put_line(v_r);
      6  end;
      7  /
    100
    PL/SQL procedure successfully completed.
    from bash:
    testproc.sh:
    #!/bin/bash
    (echo 'set serveroutput on';
    echo 'declare';
    echo 'v_r int;';
    echo 'begin';
    echo 'my_proc(10,v_r);';
    echo 'dbms_output.put_line(v_r);'
    echo 'end;';
    echo '/';) | sqlplus -s u1/u1
    Console:
    oracle@mob-ubuntu:~$ chmod u+x testproc.sh
    oracle@mob-ubuntu:~$ ./testproc.sh
    100
    PL/SQL procedure successfully completed.With kind regards
    Krystian Zieja

  • Problem while calling concsub from shell script

    Hi All,
    I am facing problem when I am trying to run CONCSUB utility from shell script.The same works well when I try it from command line.The only prob I am facing from shell script is assigning values to temporary variables.
    This is how my script looks
    #!/bin/bash
    export PARM5="$5"
    export PARM6="$6"
    export PARM7="$7"
    echo "INTPARM5=\"$PARM5\""
    echo "INTPARM6=\"$PARM6\""
    echo "INTPARM7=\"$PARM7\""
    echo $FND_TOP/bin/CONCSUB $1 ONT 'Order Management Super User, Vision Operations (USA)' $3 WAIT=Y CONCURRENT ONT $PROGRAM "$INTPARM5" "$INTPARM6" "$INTPARM7"When I try to run the above shell based concurrent program it doesn't pass the parameters as expected and it errors out saying "Wrong number of arguments to call the procedure"
    I tried my luck from some of the previous posts ({thread:id=2360776} ),but to vain
    If anyone has any ideas,please suggest!!
    Thanks in advance!!
    Edited by: sandy on May 4, 2013 12:54 PM

    Here are your proofs
    Proocedure
       PROCEDURE abc(--p_errbuf            OUT   VARCHAR2,
                                                --p_errcode           OUT   VARCHAR2,
                                 p_order_no          IN    NUMBER DEFAULT NULL,
                                                p_customer_id       IN    NUMBER DEFAULT NULL,
                                 p_name              IN    VARCHAR2 DEFAULT NULL
          IS
                    v_cname    VARCHAR2(200);
               v_ordered_date DATE;
               v_order_number  NUMBER;
              v_order_type    VARCHAR2(200);
    BEGIN
                fnd_file.put_line(fnd_file.output, 'Begin Execution');
       SELECT DISTINCT ac.customer_name,
                    d.ordered_date ordered_date,
                    d.order_number order_number,
                    x.NAME order_type
            INTO   v_cname
               ,v_ordered_date
               ,v_order_number
               ,v_order_type
               FROM oe_order_headers_all d,
                    oe_transaction_types_tl x,
                    wsh_delivery_details b,
                    wsh_delivery_assignments c
                    ,ar_customers ac
              WHERE 1 = 1
                AND ac.customer_id = b.customer_id
                AND d.order_type_id = x.transaction_type_id
                AND x.LANGUAGE = 'US'
                AND b.released_status = 'B'
                AND b.source_header_id = d.header_id
                AND c.delivery_detail_id = b.delivery_detail_id
                AND d.order_number=NVL(p_order_no,d.order_number)
                AND ac.customer_id = NVL(p_customer_id,ac.customer_id)
             AND x.name=NVL(p_name,x.name)
                AND NOT EXISTS (SELECT 1
                                FROM wsh_delivery_details b
                               WHERE 1 = 1
                                      AND b.released_status != 'B'
                                      AND b.source_header_id = d.header_id)
                                       --BETWEEN ('1213794') and ('1213797'))
                AND rownum<2;
            INSERT INTO xxc_temp(customer_name,ordered_date,order_number,order_type) VALUES(v_cname,v_ordered_date,v_order_number,v_order_type);
            COMMIT;
             fnd_file.put_line(fnd_file.output, 'Order Number is' || v_order_number);
             fnd_file.put_line(fnd_file.output, 'Order Type is'   || v_order_type);
       END;Script
    #!/bin/bash
    set -x
    export PARM5="$5" 
    export PARM6="$6"
    export PARM7="$7"
    sqlplus -s $1 <<EOF
    set head off feed off serverout on size 1000000
    exec abc('$PARM5','$PARM6','$PARM7');
    exit
    EOFNow when I run the 'XX Order Detail CSV Report' I get the below log and no Output
    +---------------------------------------------------------------------------+
    Application Object Library: Version : 12.0.0
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    XXKES_PDF_TRANSFER module: XX Order Detail CSV Report
    +---------------------------------------------------------------------------+
    Current system time is 06-MAY-2013 05:05:56
    +---------------------------------------------------------------------------+
    + export PARM5=66432
    + PARM5=66432
    + export PARM6=
    + PARM6=
    + export PARM7=Mixed
    + PARM7=Mixed
    + sqlplus -s APPS/APPS
    +---------------------------------------------------------------------------+
    Executing request completion options...
    Output file size:
    0
    +------------- 1) PRINT   -------------+
    Disabling requested Output Post Processing.  Nothing to process.  The output of the request is zero byte.
    +--------------------------------------+
    Finished executing request completion options.
    +---------------------------------------------------------------------------+
    Concurrent request completed successfully
    Current system time is 06-MAY-2013 05:05:56
    +---------------------------------------------------------------------------+After the concurrent program executed I queried the table xxc_temp and here you see the data
    SQL> select * from xxc_temp;
    CUSTOMER_NAME
    ORDERED_D ORDER_NUMBER ORDER_TYPE
    A. C. Networks
    18-FEB-13        66432 MixedMy procedure fetches the data fro given set of i/p parameters but it doesn't give o/p coz it's a host based conc program.Please advise if there's a way to get the o/p in a host based conc program
    Thanks!!

  • Passing params from SQL file to Shell Script and then from Shell to SQL Fil

    Afternoon guys,
    Have a fun question for all you gurus in shell scripting out there. I have a shell script that is calling 2
    different SQL programs. My objective is to pass a variable called request_number from one sql program
    to the shell script and then from the shell script back to another SQL program. I will explain why I
    need this to happen.
    Here is what the shell script looks like which calls sql programs student_load_a.sql and
    student_load_b.sql. Student_load_a.sql basically creates the control file (.ctl) which is needed for the
    SQL*Loader and then student_load_b.sql reads the table that was just loaded and does the main
    processing. My main objective here is to be passing the request_number which is being generated
    using an Oracle Sequence in student_load_a.sql and using this generated number in my main
    processing in student_load_b.sql to select records from the table based on request_number.
    Any ideas ?Any help or recommendations is welcome and appreciated.
    *1. Shell Script*
    # Accept system input parameters
    p_user_id=$1
    p_job_id=$2
    # Create control files for sqlload
    sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_a.sql $p_job_id
    exit_status=$?
    # Do sqlloads
    sdesqlldr.exe userid=$p_user_id control=student_load-$p_job_id.ctl \
                                                 log=student_load-$p_job_id.log \
                                                 bad=student_load-$p_job_id.bad
    exit_status=$?
    # Main processing
    # sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id $p_request_number
    sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id
    exit_status=$?
    exit 0*2. student_load_a.sql (Would like to pass back the Sequence Number back to shell script and then use in student_load_b.sql*
    -- Accept system input parameters
    define p_job_id = &1
    spool student_load-$p_job_id.ctl
    select
    'append into table TMP_STUDENT_LOAD
    FIELDS TERMINATED BY '','' optionally enclosed by ''"''
    trailing nullcols
    (request_number CONSTANT ' || '''' || request_number_seq.nextval || ''',
    student_id)'
    from   dual
    spool off;
    exit 0;
    {code}
    *3. student_load_b.sql (This is a big file so I am only adding code that is relevant for the SQL)*
    {code}
    declare
      v_request_number    number(6);
      v_student_id                  number(7);
      cursor cur_student_load is
        select  student_id
        from   TMP_STUDENT_LOAD
        where  request_number = v_request_number
        order by 1;
    begin
        v_user_id := '&1';
        v_job_id := &2;
        -- This is the variable I would like to be be passing from shell script to student_load_b.sql
        -- v_request_number = '&3';
         open  cur_student_load;
         fetch cur_student_load into v_student_id;
          exit when cur_student_load%notfound;
          .... more logic of if then else in here
         close cur_student_load;
    end;
    {code}
    Edited by: RDonASnowyDay on Jan 29, 2010 4:03 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    How come you are mixing WinDoze script (*.exe) with Unix?
    You are aware that you will be passing the password along with the user id to the second sql script?
    I will assume Unix ksh:
    # Accept system input parameters
    p_user_id=$1
    p_job_id=$2
    # Create control files for sqlload
    p_seqno=`sqlplus -s $p_user_id @$STUDENT_PATH/student_load_a.sql $p_job_id`
    exit_status=$?
    # Do sqlloads
    sqlldr userid=$p_user_id control=student_load-$p_job_id.ctl \
           log=student_load-$p_job_id.log \
           bad=student_load-$p_job_id.bad
    exit_status=$?
    # Main processing
    # sqlplus -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id $p_request_number
    sqlplus -s $p_user_id @$STUDENT_PATH/student_load_b.sql \
               $p_user_id $p_job_id $p_seqno
    exit_status=$?
    exit 0And the first sql script would look like this:
    -- student_load_a.sql
    -- Accept system input parameters
    set echo off pages 0 feed off lin 80 trims on ver off
    def p_job_id = &1
    col seqno NEW_VALUE seqno
    select request_number_seq.nextval seqno from dual;
    set term off
    spool student_load-$p_job_id.ctl
    select
    'append into table TMP_STUDENT_LOAD
    FIELDS TERMINATED BY '','' optionally enclosed by ''"''
    trailing nullcols
    (request_number CONSTANT ''&&seqno'',
    student_id)'
    from   dual
    spool off;
    exit 0;
    {code}
    :p                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Accept input from Shell script in sql*plus

    Hey! Guys..
    i need the following info.
    I am running a shell script from sql*plus. I need to accept a value from shell script into my .sql file.
    thanks..
    Harsh.

    prompt for input, pass to another shell
    # contract_status_prompt.sh
    read udate?"Enter week-ending date in format dd-mmm-yyyy: "
    contract_status_update.sh $udate >$FDWLOG/current/contractstatusupdate`date +%d%h%y`.log
    echo `date`
    # End contract_status_prompt.sh
    Read the variable passed and use in SQLPlus:
    # contract_status_update.sh
    echo "Running contract_status.sh"
    echo "create records for contract_status"
    echo `date`
    echo " "
    echo " date used is "; print $1
    echo " "
    sqlplus <<exit
    @$FDWSQL/sqlparms
    set time on
    prompt *** Set contract_status_period ***
    update contract_status_period
    set period_date = '$1';
    commit;
    exit
    etc.

  • Can I call host file ( Unix Shell script ) from Oracle 10g trigger

    Hi,
    I am new to Oracle 10g. Can I call host file ( unix shell script ) from Oracle 10g trigger ?. I know it is possible. Pl explain me with small example
    thanks & regards
    parag

    user12009546 wrote:
    Hi,
    I am new to Oracle 10g. Can I call host file ( unix shell script ) from Oracle 10g trigger ?. I know it is possible. Pl explain me with small example
    thanks & regards
    paragIf you are in 10g, you can simple call shell script from DBMS_SCHEDULER:
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'TEST_SCRIPT',
    job_type => 'EXECUTABLE',
    job_action => 'PATH_OF_YOUR_SCRIPT',
    start_date => SYSDATE,
    repeat_interval => 'FREQ=MINUTELY; INTERVAL=1',
    enabled => TRUE,
    comments => 'Shell script from Oracle'
    END;
    /

  • Calling a java code from shell script.

    Hi all,
    I want to access a method of java class from a unix shell script.basiacally I want to know how to access a java code from a shell scriptt.If anybody has any info on this , kindly revert back to me.
    Rgds,
    Satya

    Hi,
    Suppose I hv a main() method.
    Then how to access that class from Shell Script.
    Can u send me the piece os compiling and running process for it.
    Rgds,
    Satya

Maybe you are looking for

  • Proforma Invoice in Stock transfer Intra company

    Hi Gurus, I am trying to make Proforma Invoice in STO Intra company. But it is giving the errror "Not relevant for billing". Actually i want to create a excise Invoice from this Pro forma Invoice. I have also maintained NLN item category in Copy cont

  • Query regarding a report level variable

    When I create a variable in webi report and in the variable formula when I use a universe measure object called Amount_Sold whose select contains an aggregate function like sum(shop_facts.Amount_Sold) in universe then my variable in webi report shoul

  • Calling the next number in an array through a function?

    ow do I request the next number in an array? For example - currently being used for a loop: for (i=0; i = levelSettings[0]; i++) But when the function (named - NextLevel() ) is called I would like that loop to call the next number in that array. Exam

  • Auto Create Outbound Delivery and Shipment from IDoc

    Hi Ppl, Currently, we have a transport company which handles all our transportation of goods to our customer. We develop a project, phase 1 which we automatically sends sales order in form of IDocs to our transport company and they in turn we send us

  • Br*tools Studio installation FAILED

    HI ALL, i downloaded br tools studio 7.10(2), from sdn and trying to install on windows 2003 on sap ecc6.0 with basis patch level 9.0. but it keep failing to install without any error logs. is there anything else i need. please help me out on this in