# SQL Script HELP Requested.

**URL:** <https://community.unix.com/t/sql-script-help-requested/341921>\
**Category:** Shell Programming and Scripting\
**Created:** [April 19, 2014, 3:31pm UTC](https://community.unix.com/t/sql-script-help-requested/341921 "2014-04-19T15:31:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anirudhkashikar](https://community.unix.com/letter_avatar/anirudhkashikar/32/6_22734026db12803ebb3e059622ac3534.png) [@anirudhkashikar](https://community.unix.com/u/anirudhkashikar)\
**Post date:** [April 19, 2014, 3:31pm UTC](https://community.unix.com/t/sql-script-help-requested/341921/1 "2014-04-19T15:31:06Z")

</div>

Hello ALL ,

i am requesting help on for this script i am preparing to get the result of a query in a excel sheet :

current Error:  
Script : NO Excel file created.

requesting to know where i am going wrong.

```nohighlight
#!/bin/ksh
#############################################################################
#NAME : OGS_TESTAK.ksh
#############################################################################

#############################################################################
# function : sql_getquery
#############################################################################
function sql_getquery
{
typeset SqlOut
SqlOut=`sqlplus -s ${CON_STR_ENB} << EOF
set feedback off
set pagesize 2000
set newpage none
set output off

spool $Impact_file

select a,b,c from D where e='122323';

${SQL_MODE};

spool off

exit
EOF`

cat $IMPACT_FILE >> $LOG_FILE (path will be given by me)

return $SUCCESS
}

#############################################################################
# function : exit_process
#############################################################################
function exit_process
{
typeset ExitCode=$1

case $ExitCode in
        $SUCCESS)
                (cat $LOG_FILE ; uencode $IMPACT_FILE $IMPACT_FILE) | mailx -s "[IMPACT] $CLIENT $TICKET IMPACT" $EMAILRECIP
                ;;

        $FAILURE)
                printf "script failed"
                mail -s "test -ak! failed" $EMAILRECIP
                ;;
esac

exit $ExitCode
}
#############################################################################
# function : main
# purpose : Setup globals, functions
#############################################################################
# main()
typeset -r CON_STR_ENB=c1/c2@c3
typeset -r SPOOL_FILE=${SCRIPT_NAME}_${TS}.lst
typeset -r SQL_MODE=commit
typeset -r LOG_FILE=${SCRIPT_NAME}_${TS}.log
typeset -r IMPACT_FILE=Customer_Impact.xls
typeset -r EMAILRECIP=a@abc.com
#############################################################################
# script complete, send email and exit
#############################################################################
exit_process $SUCCESS

```

---

<div class="post-metadata">

**Author:** ![SriniShoo](https://community.unix.com/letter_avatar/srinishoo/32/6_22734026db12803ebb3e059622ac3534.png) [@SriniShoo](https://community.unix.com/u/SriniShoo)\
**Post date:** [April 20, 2014, 12:55am UTC](https://community.unix.com/t/sql-script-help-requested/341921/2 "2014-04-20T00:55:58Z")

</div>

I could see the script has 2 functions  
sql\_getquery  
exit\_process  
You are calling the function 'exit\_process' at the end but you are not calling the function 'sql\_getquery' any where in the script.  
call the function 'sql\_getquery' before 'exit\_process'

---

<div class="post-metadata">

**Author:** ![anirudhkashikar](https://community.unix.com/letter_avatar/anirudhkashikar/32/6_22734026db12803ebb3e059622ac3534.png) [@anirudhkashikar](https://community.unix.com/u/anirudhkashikar)\
**Post date:** [April 20, 2014, 6:47am UTC](https://community.unix.com/t/sql-script-help-requested/341921/3 "2014-04-20T06:47:19Z")

</div>

Thank you .. appreciate the help...
