Solved

Unix Bourne Shell / SQLPLUS error

Posted on 2012-04-12
4
2,002 Views
Last Modified: 2012-07-11
I am using the following connect logic in a script which works fine with no errors
   sqlplus /nolog <<EOF >> $LOG 2>&1
   CONN $DATABASE_2
   WHENEVER SQLERROR EXIT sql.sqlcode ROLLBACK;
   set serveroutput on
   set echo on
   set lin 140
   BEGIN     
      DBMS_OUTPUT.put_line ('Replace with TEST procedure');         
   END;
   /          
   exit;
!EOF

Open in new window


However, when I try to put this logic in a do/while loop, I get this error:

Syntax error at line 89 : `<<' is not matched.

So, I followed advice I found via google and changed it to:
sqlplus /nolog <<
EOF >> $LOG 2>&1
CONN $DATABASE_2
WHENEVER SQLERROR EXIT sql.sqlcode ROLLBACK;
   set serveroutput on
   set echo on
   set lin 140
   BEGIN     
      DBMS_OUTPUT.put_line ('Replace with TEST Procedure');         
   END;
   /          
   exit;
!EOF

Open in new window


This gives me the following error: Syntax error at line 91 : `newline or ;' is not expected.

Any connection pointers would be greatly appreciated. I am at a loss as to why it's erroring out within a loop.
Thanks!
0
Comment
Question by:Marilyn1374
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 150 total points
ID: 37840599
the ending EOF should look exactly like the the beginning EOF after the <<
and there should be no other whitespace or other characters on the line
0
 
LVL 27

Assisted Solution

by:sujith80
sujith80 earned 150 total points
ID: 37841262
Try to remove the "!" before the second EOF, see below

counter=1
LOG=zxxx.txt
while [ $counter -lt 4 ]
do
   sqlplus /nolog <<EOF >> $LOG 2>&1
   CONN duser/dpwd@ddb
   WHENEVER SQLERROR EXIT sql.sqlcode ROLLBACK;
   set serveroutput on
   set echo on
   set lin 140
   BEGIN
      DBMS_OUTPUT.put_line ('Replace with TEST procedure');
   END;
   /
   exit;
EOF
counter=$(( $counter + 1 ))
done

Open in new window

0
 

Author Comment

by:Marilyn1374
ID: 38176816
Unfortunately neither of these worked, thought they should have. I think it's something in how this client is set up. I modified my code to not loop. Assigning half to each expert
0
 

Author Closing Comment

by:Marilyn1374
ID: 38176823
Unfortunately neither of these worked, thought they should have. I think it's something in how this client is set up. I modified my code to not loop. Assigning half to each expert
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Difference in number of minutes between 2 timestamps 16 39
Web Service from a stored procdure oracle 10 49
aix unix tar error 3 42
'G_F01' is not a procedure or is undefined 3 12
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now