DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Hi

  1. #1
    Join Date
    Jun 2008
    Posts
    1

    Question Hi

    I am new to sqlplus as well as shell.
    have an req where I need to send the .sql file and the place where the script has to create a .csv file with the out of the query as a parameter when the shell script is called.

    Currently My script looks like this.

    #!/bin/ksh
    set timing on
    Filename=$1
    Sqlfile=$2
    sqlplus -S username/Pwd@dbname< set timing off heading on feedback off pagesize 0 linesize 250
    WHENEVER SQLERROR EXIT FAILURE
    WHENEVER OSERROR EXIT FAILURE
    spool ${Filename}
    @${Sqlfile}
    spool off;

    Exit;
    EOF

    I am calling the script like this

    ./hema.sh path/sqlfile.csv path/sqlfile.sql


    I am able to find that the paramaters are not taken by the sqlplus commands
    and hence not taking the exact sql which needs to be executed and neither creating a .csv file with proper name.

    Could anyone help me in getting this sorted out as its very urgent.

    Thanks
    Hema.

  2. #2
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Talking Try it this way:

    PHP Code:
    #!/bin/ksh
    Filename=$1
    Sqlfile
    =$2
    sqlplus 
    -S username/Pwd@dbname <<EOF 
    set timing off heading on feedback off pagesize 0 linesize 250 trims on
    WHENEVER SQLERROR 
    EXIT FAILURE
    WHENEVER OSERROR 
    EXIT FAILURE
    spool 
    ${Filename}
    @${
    Sqlfile}
    spool off;

    Exit;
    EOF 
    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width