Unix-Sql Loop error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix-Sql Loop error
# 1  
Old 02-05-2007
Unix-Sql Loop error

Hi,

I am getting the error "No matching <<", when i run the below. Is it that we can't execute SQL in a Unix loop. I am executing a SQL in a loop. Is it the EOF is written wrongly.


. /opt/app/wlsconfigv61/domains/profiles/oracleV901.profile
export DBUSER=ecdb01

set -A DBINSTANCE ECDBP01P ECDBP02P ECDBP03P ECDBP04P ECDBP05P ECDBP09P ECDBP10P ECDBP11P ECDBP12P ECDBP13P ECDBP14P ECDBP15P

SQLPLUS=${ORACLE_HOME}/bin/sqlplus

SQL_func()
{
filename=${3}
${SQLPLUS} -s $2/$3@$4 <<EOF
spool /export/home/mpdwwcz/sqlOutput/${filename}
set trimspool on
set heading off
set feedback off
set linesize 2000
set arraysize 4000
set pagesize 0
@/export/home/mpdwwcz/IICP_SH/sqlQuery.sql
spool off
exit
!EOF
exit $?
}

if [ ! -x ${SQLPLUS} ]
then
echo "ERROR: Cannot find ${SQLPLUS}. Set the environment variables ORACLE_HOME etc..."
exit -1
fi

i=0
while [ i -lt 11 ]
do
PASSWD=`/opt/app/cbs/CBSDBSecurity/Scripts/ksh/CBSGetPw ${DBINSTANCE[i]} $DBUSER`

echo "DBINSTANCE Is : ${DBINSTANCE[i]}"
echo "DBUSER Is : $DBUSER"
rm /export/home/mpdwwcz/sqlOutput/${filename}
SQL_func $SQLPLUS $DBUSER $PASSWD $DBINSTANCE[i]
i=`expr i + 1`
done
exit $?
# 2  
Old 02-05-2007
change !EOF to EOF
# 3  
Old 02-05-2007
still i am getting the error. Is it that we should not run SQL in a loop, as when i remove the SQL from the function and execute as a seperate script, it works
# 4  
Old 02-05-2007
Hey thanks actually it's working.....Thanks a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

for loop with internal unix command in statement throwing error

Hi I've gotten a plugin script that won't run. I keeps throwing an error at the following line. for BARCODE_LINE in `cat ${TSP_FILEPATH_BARCODE_TXT} | grep "^barcode"` do #something done The error reads ... (3 Replies)
Discussion started by: jdilts
3 Replies

2. Shell Programming and Scripting

Need to capture error of sybase sql in unix

Hi Gurus, I am very new in Unix, I have 1 script, in which I am truncating the table , then BCP the data in Sybase table, and then loading the data from sybase table to sybase table. every thing is working fine, but the problem is with Error. I made some hanges in my insert statement so... (1 Reply)
Discussion started by: aksar
1 Replies

3. Shell Programming and Scripting

UNIX/SQL loop to spool files!!

I want to spool files from unix using a sql script that would take values from another sql query within the KSH script.. unix loop select order_date from date_tbl for each order_Date i need to call this spool script with the value sqlplus scott/tiger@order_db @/ordspool/order_date.sql... (2 Replies)
Discussion started by: vr23
2 Replies

4. Shell Programming and Scripting

How to use sql data file in unix csv file as input to an sql query from shell

Hi , I used the below script to get the sql data into csv file using unix scripting. I m getting the output into an output file but the output file is not displayed in a separe columns . #!/bin/ksh export FILE_PATH=/maav/home/xyz/abc/ rm $FILE_PATH/sample.csv sqlplus -s... (2 Replies)
Discussion started by: Nareshp
2 Replies

5. 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

6. Shell Programming and Scripting

unix variables from sql / pl/sql

How do I dynamically assign the below output to unix shell variables so I can build a menu in a shell script? Example: var1 = 1 var2= SYSTEM var3 = 2 var4= UNDOTBS1 and so on, then in the shell script I can use the variables to build a menu. set serveroutput on declare... (2 Replies)
Discussion started by: djehres
2 Replies

7. UNIX for Advanced & Expert Users

sql load error in unix

When i try to run a job in unix, i am getting sqlload error as, sqlload : file not found. Can any one please let me know whats the reason for this.. The PATH & ORACLE_HOME paths names are correct... thanks here is the script : plz hv a look TABLE_NAME= tablename... (1 Reply)
Discussion started by: abhi_123
1 Replies

8. UNIX for Dummies Questions & Answers

Problem with while loop and SQL

Connected to oracle database sqlplus << EOF $CONNECTSTR set heading off set trimspool on set feedback off select ID,DATE from sysadm.TEST where VALUE = 'A' order by ID; value_id = ID value_date = DATE EOF 1. Is it possible to reference the values, ID,DATE in unix shell script. 2.... (20 Replies)
Discussion started by: nandajk
20 Replies

9. UNIX for Advanced & Expert Users

Bus error(coredump) while running SQL*Loader in HP Unix 11

Hi All, I am getting coredump error, when I try to execute Oracle SQL*Loader from Shell script in Unix environment. But SQL*Loader from local machine runs fine with same database. SQL*Loader: Release 9.2.0.6.0 - Production on Mon Apr 23 05:23:47 2007 Copyright (c) 1982, 2002, Oracle... (3 Replies)
Discussion started by: srinivas_paluku
3 Replies

10. Shell Programming and Scripting

Error while trying to fire a PL/SQL thro Unix Script

hi , I tried running a PL/SQL script through unix shell script. But am getting the following error. "Message file sp1<lang>.msb not found Error 6 initializing SQL*Plus " Kindly suggest. Regards, Samit (5 Replies)
Discussion started by: dharmesht
5 Replies
Login or Register to Ask a Question