Exit from SQLPLUS


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Exit from SQLPLUS
# 1  
Old 10-05-2011
Exit from SQLPLUS

Code:
#!/bin/ksh

Folder_Name=$1
Workflow_Name=$2

Log_Dir=/home/parm_file
Log_File=parm_file_log.log

echo "Running" > $Log_Dir/$Log_File
echo " " >>  $Log_Dir/$Log_File


Parm_Dir=/ParmFiles/$Folder_Name
Parm_File=$Workflow_Name.parm
touch $Parm_Dir/$Parm_File

echo "Calling SQL"  >> $Log_Dir/$Log_File
echo " " >>  $Log_Dir/$Log_File        

echo "SQLPLUS Cmd"  >> $Log_Dir/$Log_File
echo "  " >> $Log_Dir/$Log_File  

sqlplus -s USR/PW@DB  <<EOF >$Log_Dir/test.dat
     
     set term off
     set head off
     set trims on
     set pages 0
     set feedback off
         set linesize 1000
          
             
     SELECT session_name || '|' || mapping_name || '|' || parm_name || '|'|| parm_val FROM spasupa.v_parm_ref_table where FOLDER_NAME = '$Folder_Name' and WORKFLOW_NAME = '$Workflow_Name';
     /
     exit;                      
         EOF
###### The script exits right here. Anyway I can fix that? :wall:         

echo "SQL Complete"  >> $Log_Dir/$Log_File
echo "  " >> $Log_Dir/$Log_File      

echo "Write Parm"  >> $Log_Dir/$Log_File
echo "  " >> $Log_Dir/$Log_File  

file="$Log_Dir/test.dat"

while read line
do
     echo "$line"
done <"$file"

------------------- This is my log entries ----------------

Code:
Running
 
Creating Parm File wf_m_Test_Parm_File.parm  in  /gfs/ParmFiles/DevWorkArea-SPASUPA
  
Calling SQL
 
SQLPLUS Cmd

Moderator's Comments:
Mod Comment Video on how to use code tags

Last edited by sats2059; 10-06-2011 at 01:51 PM..
# 2  
Old 10-05-2011
What do you see on the shell prompt when you run this script?
Can you copy/paste the execution on here?

tyler_durden
# 3  
Old 10-06-2011
"I am Jacks Failed Shell script"

$ sh parm_test.sh DevWorkArea-SPASUPA wf_m_Test_Parm_File
$ ls
parm_file_log.log parm_test.sh test.dat
$ more parm_file_log.log
Running

Creating Parm File wf_m_Test_Parm_File.parm in /gfs/informaticadata/IS_86_ASCI
I_GRID/ParmFiles/DevWorkArea-SPASUPA

Calling SQL

SQLPLUS Cmd

$ more test.dat
s_m_Test_Parm_File|m_Test_Parm_File|$$MAP_PARAM|01022011
s_m_Test_Parm_File|m_Test_Parm_File|$$MAP_PARAM1|parameter_value
s_m_Test_Parm_File|m_Test_Parm_File|$$MAP_PARAM|01022011
s_m_Test_Parm_File|m_Test_Parm_File|$$MAP_PARAM1|parameter_value
# 4  
Old 10-06-2011
The "EOF" string that closes the here document should be at the very start of the line.
Also I do not believe you need the slash between the SQL statement and the exit statement, that will cause the SQL to be executed a second time.

You do not need to run it like:
Code:
$ sh parm_test.sh blah blah...

when the shebang tells your login shell to use ksh to run it.

Just use:
Code:
$ parm_test.sh blah blah...


Last edited by gary_w; 10-06-2011 at 03:29 PM..
This User Gave Thanks to gary_w For This Post:
# 5  
Old 10-06-2011
SmilieSmilieSmilie Thanks gary_w! worked like a charm. [I was banging my head over why the sql data is being duplicated too, you saved me another thread or post Smilie]
# 6  
Old 10-06-2011
My pleasure, glad to help.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Problem on SQLplus command ""bash: sqlplus: command not found""

Hi all, i face an error related to my server ""it's running server"" when i use sqlplus command $ sqlplus bash: sqlplus: command not found the data base is up and running i just need to access the sqlplus to import the dump file as a daily backup. i already check the directory... (4 Replies)
Discussion started by: clerck
4 Replies

2. Shell Programming and Scripting

Sqlplus error - sqlplus -s <login/password@dbname> : No such file or directory

i am using bash shell Whenever i declare an array, and then using sqlplus, i am getting sqlplus error and return code 127. IFS="," declare -a Arr=($Variable1); SQLPLUS=sqlplus -s "${DBUSER}"/"${DBPASS}"@"${DBASE} echo "set head off ; " > ${SQLCMD} echo "set PAGESIZE 0 ;" >> ${SQLCMD}... (6 Replies)
Discussion started by: arghadeep adity
6 Replies

3. Shell Programming and Scripting

Need the difference between exit 1 & exit 7

Hi In one of the script I am seeing some thing like exit 7,exit 1,exit 2,exit 3,exit 9,exit6.What is the difference between all of this exit.Can anyone help here please (3 Replies)
Discussion started by: ginrkf
3 Replies

4. Shell Programming and Scripting

Sqlplus Help

When i run the following script am getiing the output correct but i want to get it in the form of a table, could any one help me please. the script is a s follows count=`sqlplus -s $ORACLE_ACCOUNT << EOF set heading off set wrap on set feedback off column ChangeNumber format a12 column... (9 Replies)
Discussion started by: jhon1257
9 Replies

5. HP-UX

how can i call sqlplus?

i am new working with hp-ux but i had to because of my job. so i want to execute some sql scripts but when i call sqlplus to run them it responds /sbin/sh: sqlplus not found. i have oracle 8.1.7 installed. what should i do sorry if this sounds too easy but i am now learning. The same... (13 Replies)
Discussion started by: theodore
13 Replies

6. UNIX for Dummies Questions & Answers

what is meaning of exit(0) and exit(1)

can u tell me what is the meaning of exit(0),exit(1),exit(2) what is diff amonng these. Amit (1 Reply)
Discussion started by: amitpansuria
1 Replies

7. Programming

exit(0) versus exit(1)

What is the difference between using exit(0) and exit(1) to exit a program? Which should I use? (9 Replies)
Discussion started by: enuenu
9 Replies

8. Shell Programming and Scripting

Sqlplus

I am looking to loop round a load of files and execute each in sqlplus, I have looked at the forum to see what was posted in the past, but most of the examples seem to use the sql being passed in through the script, which is not really what I am looking for, can someone tell me if the code below is... (9 Replies)
Discussion started by: LiquidChild
9 Replies

9. Shell Programming and Scripting

Sqlplus

Hi all, I am new to SQLPLUS, can anyone tell me what is the following codes doing? DECLARE cursor c1 is select bts_int_id, max(ave_busy_tch/res_av_denom14) maxBusyTch from p_nbsc_res_avail where to_char(period_start_time,'yyyymmdd')=to_char((sysdate-1),'yyyymmdd') group by... (4 Replies)
Discussion started by: antkiu
4 Replies

10. UNIX for Dummies Questions & Answers

Where can I find a list of exit codes? (Exit code 64)

I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Discussion started by: jkuchar747
3 Replies
Login or Register to Ask a Question