- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Getting Exact Oracle errors returned by SQL from S...
Operating System - HP-UX
1753487
Members
4731
Online
108794
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2004 02:34 AM
тАО09-06-2004 02:34 AM
Getting Exact Oracle errors returned by SQL from Shell script
Dear friends.
Iam calling some SQL scripts from Shell sript (HP UNIX) in the following way.
SCRIPTERROR1=0
SQLRESULTS1=`sqlplus -s user/$pass
@$SCRIPTNAME < $tmp/tmp.err`
echo $SQLRESULTS1 | grep -Eq 'ORA-|SP2-'
GREPOUTPUT2=$?
if [ $GREPOUTPUT1 -eq 0 ]
then
echo "********************************"
echo "ERROR 4 :"
echo "Error While droping:" echo "*******************************"
exit 99
fi
The echo output of "$SQLRESULTS1" contains
some other junk data along with oracle errors. We observed that the echo output displaying all file names in that directory along with Oracle errors.
Can please suggest me how to get only oracle errors in the echo output.
Thanks in advance
Iam calling some SQL scripts from Shell sript (HP UNIX) in the following way.
SCRIPTERROR1=0
SQLRESULTS1=`sqlplus -s user/$pass
@$SCRIPTNAME < $tmp/tmp.err`
echo $SQLRESULTS1 | grep -Eq 'ORA-|SP2-'
GREPOUTPUT2=$?
if [ $GREPOUTPUT1 -eq 0 ]
then
echo "********************************"
echo "ERROR 4 :"
echo "Error While droping:" echo "*******************************"
exit 99
fi
The echo output of "$SQLRESULTS1" contains
some other junk data along with oracle errors. We observed that the echo output displaying all file names in that directory along with Oracle errors.
Can please suggest me how to get only oracle errors in the echo output.
Thanks in advance
Time and Tide wait for none
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2004 03:04 AM
тАО09-06-2004 03:04 AM
Re: Getting Exact Oracle errors returned by SQL from Shell script
Hi,
not sure I read the script properly and/or if I understand fully yuor pb.
Anyway :
1) I would check a return code for the sqlplus run
e.g.
SQLRESULTS1=$(sqlplus -s user/$pass
@$SCRIPTNAME > $tmp/tmp.err)
RET=$?
2) in your SQL I would start probably with :
whenever sqlerror exit 99 ;
(hence test of return code in (1))
3) I would redirect output to the temp file (did I read it ok ?)
then :
if [[ $RET -ne 0 ]]; then
grep -e 'ORA-|SP2-' $tmp/tmp.err
fi
you will get the errors
Regards,
Jean-Luc
not sure I read the script properly and/or if I understand fully yuor pb.
Anyway :
1) I would check a return code for the sqlplus run
e.g.
SQLRESULTS1=$(sqlplus -s user/$pass
@$SCRIPTNAME > $tmp/tmp.err)
RET=$?
2) in your SQL I would start probably with :
whenever sqlerror exit 99 ;
(hence test of return code in (1))
3) I would redirect output to the temp file (did I read it ok ?)
then :
if [[ $RET -ne 0 ]]; then
grep -e 'ORA-|SP2-' $tmp/tmp.err
fi
you will get the errors
Regards,
Jean-Luc
fiat lux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2004 03:42 AM
тАО09-06-2004 03:42 AM
Re: Getting Exact Oracle errors returned by SQL from Shell script
Are you getting input from $tmp/tmp.err file for sql operation or redirecting it???
If you want to put the contents on to $tmp/tmp.err file then, use as,
SQLRESULTS1=`sqlplus -s user/$pass
@$SCRIPTNAME > $tmp/tmp.err`
Else to append with old contents then,
SQLRESULTS1=`sqlplus -s user/$pass
@$SCRIPTNAME >> $tmp/tmp.err`
echo $SQLRESULTS1 | grep -Eq 'ORA-|SP2-'
GREPOUTPUT2=$?
if [ $GREPOUTPUT1 -eq 0 ]
--> we can simplify as,
echo $SQLRESULTS1 | grep -Eq 'ORA-|SP2-'
if [[ $? -eq 0 ]]
then
And more you can start to debug *Everything* or this part with set -x ?
set -x
SCRIPTERROR1=0
SQLRESULTS1=`sqlplus -s user/$pass
@$SCRIPTNAME > $tmp/tmp.err`
echo $SQLRESULTS1 | egrep -q 'ORA-|SP2-'
if [ $? -eq 0 ]
then
echo "********************************"
echo "ERROR 4 :"
echo "Error While droping:"
echo "*******************************"
exit 99
fi
set +x
If you want to put the contents on to $tmp/tmp.err file then, use as,
SQLRESULTS1=`sqlplus -s user/$pass
@$SCRIPTNAME > $tmp/tmp.err`
Else to append with old contents then,
SQLRESULTS1=`sqlplus -s user/$pass
@$SCRIPTNAME >> $tmp/tmp.err`
echo $SQLRESULTS1 | grep -Eq 'ORA-|SP2-'
GREPOUTPUT2=$?
if [ $GREPOUTPUT1 -eq 0 ]
--> we can simplify as,
echo $SQLRESULTS1 | grep -Eq 'ORA-|SP2-'
if [[ $? -eq 0 ]]
then
And more you can start to debug *Everything* or this part with set -x ?
set -x
SCRIPTERROR1=0
SQLRESULTS1=`sqlplus -s user/$pass
@$SCRIPTNAME > $tmp/tmp.err`
echo $SQLRESULTS1 | egrep -q 'ORA-|SP2-'
if [ $? -eq 0 ]
then
echo "********************************"
echo "ERROR 4 :"
echo "Error While droping:"
echo "*******************************"
exit 99
fi
set +x
Easy to suggest when don't know about the problem!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-06-2004 09:15 PM
тАО09-06-2004 09:15 PM
Re: Getting Exact Oracle errors returned by SQL from Shell script
Hi Friends
Thanks for your suggestions we found that the reason for junk is for " * " in SQL output.
so we have implemented as below
SCRIPTERROR1=0
sqlplus -s ystem/$spass @$SCRIPTNAME<$tmp/tmp.err > /tmp/com_outpu.txt
SCRIPTERROR1=$?
echo " "
echo " checking data "
echo " "
grep -Eq 'ORA-|SP2-' /tmp/com_outpu.txt > /dev/null
if [ $? -eq 0 ]; then
echo " ************************************"
echo " ERROR 4"
echo "Error While droping "
cat /tmp/com_outpu.txt
echo "*********************************"
exit 1
fi
Thanks for your suggestions we found that the reason for junk is for " * " in SQL output.
so we have implemented as below
SCRIPTERROR1=0
sqlplus -s ystem/$spass @$SCRIPTNAME<$tmp/tmp.err > /tmp/com_outpu.txt
SCRIPTERROR1=$?
echo " "
echo " checking data "
echo " "
grep -Eq 'ORA-|SP2-' /tmp/com_outpu.txt > /dev/null
if [ $? -eq 0 ]; then
echo " ************************************"
echo " ERROR 4"
echo "Error While droping "
cat /tmp/com_outpu.txt
echo "*********************************"
exit 1
fi
Time and Tide wait for none
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP