SQL Script HELP Requested.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SQL Script HELP Requested.
# 1  
Old 04-19-2014
SQL Script HELP Requested.

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.




Code:
#!/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


Last edited by radoulov; 04-19-2014 at 05:32 PM..
# 2  
Old 04-20-2014
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'
# 3  
Old 04-20-2014
Thank you .. appreciate the help...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run SQL thru shell script: how to get a new line when run sql query?

Hi, this's Pom. I'm quite a new one for shell script but I have to do sql on shell script to query some information from database. I found a concern to get a new line...When I run my script, it retrieves all data as wondering but it's shown in one line :( What should I do? I'm not sure that... (2 Replies)
Discussion started by: Kapom
2 Replies

2. Shell Programming and Scripting

Help on sed requested

Hi I have a problem to resolve, I think sed is the best option, and I am not successful yet. Have a UNIX file which has records as of the 2 character state codes like NY NJ PA DE From the file I need to create this as a variable in the same script or another file -... (7 Replies)
Discussion started by: snair2010
7 Replies

3. Shell Programming and Scripting

Newbie bash scripting help requested

Hi, I'm very new to bash scripting and Linux in general. I'm running Ubuntu Server 10.04 and trying to write a bash script to launch a program. In doing so, I've come across a couple of things that I obviously don't understand. Here is a short script that exemplifies those things: ... (9 Replies)
Discussion started by: Carson Dyle
9 Replies

4. UNIX for Dummies Questions & Answers

Execute PL/SQL function from Unix script (.sql file)

Hi guys, I am new on here, I have a function in oracle that returns a specific value: create or replace PACKAGE BODY "CTC_ASDGET_SCHED" AS FUNCTION FN_ASDSCHEDULE_GET RETURN VARCHAR2 AS BEGIN DECLARE ASDSchedule varchar2(6); ASDComplete... (1 Reply)
Discussion started by: reptile
1 Replies

5. Shell Programming and Scripting

Help requested for a script with sed

Hello Folks, I would very much appreciate if I could get help/suggestions on a particular sed usage. I have to write a script to take version info from a version file, compute the image name, print error if the image does not exist. The version file looks like below: " # # version.cfg #... (3 Replies)
Discussion started by: fatimap
3 Replies

6. UNIX for Advanced & Expert Users

assistance requested (sed related)

I gotta write a command to change the accounts in /etc/passwd that use a shell other than the bash to bash shell. those accounts that dont use a shell shouldnt get modified. assuming all the shell programs end in sh and other programs dont. and the result should go into /etc/passwd.rev any hint? (4 Replies)
Discussion started by: metalwarrior
4 Replies

7. Shell Programming and Scripting

Calling SQL LDR and SQL plus scripts in a shell script

Hi- I am trying to achieve the following in a script so I can schedule it on a cron job. I am fairly new to the unix environment... I have written a shell script that reads a flat file and loads the data into an Oracle table (Table1) via SQLLDR. This Works fine. Then, I run a nested insert... (5 Replies)
Discussion started by: rajagavini
5 Replies

8. Shell Programming and Scripting

AWK issue--> Help requested

Fairly new scripter so please bare with me if what I have done below is not according to standards. Okay...heres what I am trying to do. I have a pattern that I need to search for in a directory. This gives me a list of files that includes a control file that contains totals of the line nos for... (3 Replies)
Discussion started by: alfredo123
3 Replies

9. Solaris

Your Opinion requested

Ladies/Gentlemen, I am looking for a web-based tool to keep track of my Sun inventory. The following list of fields are fields I would like to store: Root Passwd (needs to be secure) / Hostid / Console Port / IP Address / Platform / Application / Hostname . . . you get the point. Do any of... (4 Replies)
Discussion started by: pc9456
4 Replies

10. Email Antispam Techniques and Email Filtering

help requested: procmail receipes

Hello all. I want some help procmail receipe. I tried to get some mails' sender and receiptient. Then tried to send them a bash script. But it didnot work. I try a lot of variation of the below receipe. Could anyone can help what is wrong on my receipe? Or if the recepie is correct what can be... (0 Replies)
Discussion started by: kedi
0 Replies
Login or Register to Ask a Question