PROBLEM WITH ORACLE QUERY IN UNIX SCRIPT


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PROBLEM WITH ORACLE QUERY IN UNIX SCRIPT
# 1  
Old 06-24-2011
PROBLEM WITH ORACLE QUERY IN UNIX SCRIPT

hi Guys,

i have a problem with oracle query in my unix script..

I'm getting the following error while executing..

./logtab.sh: sqlplus -s "pmutv/pmutv1" << EOFSQL^Jset head off^Jinsert into sess_log(SESSION_NAME,WORKFLOW_NAME,START_TIMESTAMP,SESSION_STATUS,OUTPUT,REJECT)values(smLoadTesUha tgdb1FelkodMan,bLoadTesDomainMan,20110112,Success,36,36);^J^Jexit;^JEOFSQL: not found

enitire code is below
Code:
 
#!/bin/sh
###########################################
#                                         #
#  THIS SCRIPT FETCHES THE INFORMATION    #
#  FROM THE INFORMATICA LOG FILE AND      #
#  LOADS THE DATA IN TO THE SESS_LOG_TAB  #
#                                         #
###########################################
find /export/home/pmutv/data/  -type f -name *.4 -print > /export/home/pmutv/auto/LogFiles.txt
for i in `cat /export/home/pmutv/auto/LogFiles.txt | cut -f6 -d"/"`
  do
SESSION_NAME=`cat /export/home/pmutv/data/$i | head -1 | awk '{print $3}' | cut -f2 -d"[" |cut -f1 -d"]"`
WORKFLOW_NAME=`grep -w Workflow /export/home/pmutv/data/$i | awk '{print $4}' | cut -f2 -d"[" | cut -f1 -d"]"`
START_TIMESTAMP=`grep -iw "load start time" /export/home/pmutv/data/$i | cut -c 18-41 |  cut -f2,3,5 -d" " | sed 's/ //g'`
SESSION_STATUS=`cat /export/home//pmutv/data/$i | tail -1 | awk '{print $5}'`
OUTPUT=`grep -iw "output rows" /export/home/pmutv/data/$i | head -1 | cut -f1 -d"," | cut -f4 -d" " | cut -f2 -d"[" | cut -f1 -d"]"`
REJECTED=`grep -iw "output rows" /export/home/pmutv/data/$i | head -1 | cut -f1 -d"," | cut -f4 -d" " | cut -f2 -d"[" | cut -f1 -d"]"`
start_date=$START_TIMESTAMP
 New_date=`nawk -v Date=${start_date} '
 BEGIN { Months="  JanFebMarAprMayJunJulAugSepOctNovDec"
 year = substr(Date, 6, 4) + 0;
 day = substr(Date, 4, 2) + 0;
 month = index(Months, substr(Date, 1, 3))/3;
 printf "%04d%02d%02d", year, month, day;
 exit;
}
'`
if [ $SESSION_STATUS != "completed" ]; then
   SESSION_STATUS="Failed"
   else
   SESSION_STATUS="Success"
  fi
echo "Session Name------> $SESSION_NAME"
echo "Workflow name-----> $WORKFLOW_NAME"
echo "Load Start Time---> $New_date "
echo "Session Status----> $SESSION_STATUS"
echo "Inserts ----------> $OUTPUT"
echo "Rejects-----------> $REJECTED"
'sqlplus -s "pmutv/pmutv1" << EOFSQL
set head off
insert into sess_log values('$SESSION_NAME','$WORKFLOW_NAME','$New_date','$SESSION_STATUS','$OUTPUT','$REJECTED');
exit;
EOFSQL'
echo "$?"
done

THANKS IN ADVANCE Smilie
# 2  
Old 06-24-2011
Code:
 
'sqlplus -s "pmutv/pmutv1" << EOFSQL
set head off
insert into sess_log values('$SESSION_NAME','$WORKFLOW_NAME','$New_date','$SESSION_STATUS','$OUTPUT','$REJECTED');
exit;
EOFSQL'

Remove the single quote " ' " and just execute it.i.e

Code:
sqlplus -s "pmutv/pmutv1" << EOFSQL
set head off
insert into sess_log values('$SESSION_NAME','$WORKFLOW_NAME','$New_date','$SESSION_STATUS','$OUTPUT','$REJECTED');
exit;
EOFSQL

This User Gave Thanks to panyam For This Post:
# 3  
Old 06-24-2011
Hi,

Thanks for the replty thats working fine now..

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Korn Script to connect and query oracle database

I've been sent the following script to finish. It's supposed to connect to an oracle database, query it, and send an email if the query result value is one or more. Currently it isn't connecting properly, just giving the following error: ERROR: ORA-01017: invalid username/password; logon denied... (2 Replies)
Discussion started by: jackmorgan2007
2 Replies

2. Shell Programming and Scripting

How to run a SQL select query in Oracle database through shell script?

I need to run a SQL select query in Oracle database and have to capture the list of retrieved records in shell script. Also i would like to modify the query for certain condition and need to fetch it again. How can i do this? Is there a way to have a persistent connection to oracle database... (9 Replies)
Discussion started by: vel4ever
9 Replies

3. Shell Programming and Scripting

Problems with storing oracle sqlplus query output shell script

Hello everyone, I have a RHEL 5 system and have been trying to get a batch of 3-4 scripts each in a separate variables and they are not working as expected. I tried using following syntax which I saw a lot of people on this site use and should really work, though for some reason it doesn't... (3 Replies)
Discussion started by: rockf1bull
3 Replies

4. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

5. Shell Programming and Scripting

Shell script to query Oracle table

Hi, unix gurnis I need help for following requirement for writing a shell scritp. log in to oracle database, query one table total records (select count(*) from table1), pass the return value to a file. Thanks in advance (2 Replies)
Discussion started by: ken002
2 Replies

6. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

7. Shell Programming and Scripting

Oracle Query results to be stored in variables using unix

I want to store the sql query output into a variable #!/bin/ksh ORACLE_SID=DB01; export ORACLE_SID; export FILE_PATH=/home/asg/Tmp # Order Checking echo " removing old files " rm $FILE_PATH/Malformed_Order.txt echo " Enter the Malformed Order ....!" read orders echo "Regrade... (5 Replies)
Discussion started by: Nareshp
5 Replies

8. Shell Programming and Scripting

run oracle query remotly with shell script

hello how to run shell script to excute oracle queries on remote db ? i have tried as following sqlplus -s user/password@remote_server "select query;" but not working also this one sqlplus -s user/password@remote_server `select query;` not working :( i add this line to run another... (4 Replies)
Discussion started by: mogabr
4 Replies

9. Shell Programming and Scripting

Execute oracle query determined at runtime from a unix script

Hi I am trying to run a SQL statement from a unix script determined at runtime. It is throwing me an error. Please advise some solution to this. echo "Enter username for the database" read username echo "Enter password for the database" read password echo "Enter SQL stmt" read... (4 Replies)
Discussion started by: infyanurag
4 Replies

10. Shell Programming and Scripting

Perl script variable passed to Oracle query

Hi All, I pass a Perl script variable, whch is passed to a query to be prepared. But the problem is I have special character like '&' in this variable which are handled in a special way by the Oracle query parser. How do I get over this? my $cust_name='A&B'; my $sql="Select cust_short_name... (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question