Capturing Oracle Shutdown error


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Capturing Oracle Shutdown error
# 8  
Old 04-18-2007
Error

radoulov,

"whenever sqlerror exit" will get executed only if the oracle is up.
But whenever Oracle is in shutdown status, that time the SQL command "whenever sqlerror exit" will not get executed.

Also please see the prior two example and compare the difference.
At one instance it worked fine and gave the exit status "1" and another time the status was "0".

Please guide/correct me if Iam wrong.

Mysore Ganapati.
# 9  
Old 04-18-2007
Incomplete post! See addendum below!

Quote:
Quote:
Originally Posted by ganapati
radoulov,

"whenever sqlerror exit" will get executed only if the oracle is up.
But whenever Oracle is in shutdown status, that time the SQL command "whenever sqlerror exit" will not get executed.



Incorrect! It's SQL*Plus (client) feature, see the docs for details. For example:

Code:
$ printf "select null from dba_tables;\n" \
> | sqlplus -s / as sysdba; \
> printf "Exit status is: $?\n"
select null from dba_tables
*
ERROR at line 1:
ORA-01034: ORACLE not available


Exit status is: 0
$ printf "whenever sqlerror exit 42\n\
> select null from dba_tables;\n" \
> | sqlplus -s / as sysdba; \
> printf "Exit status is: $?\n"
select null from dba_tables
*
ERROR at line 1:
ORA-01034: ORACLE not available


Exit status is: 42

Quote:
Originally Posted by ganapati
Also please see the prior two example and compare the difference.
At one instance it worked fine and gave the exit status "1" and another time the status was "0".
[...]
Exit 1 is because of the "SP2-0306: Invalid option.".

Last edited by radoulov; 04-18-2007 at 07:26 AM..
# 10  
Old 04-18-2007
Going' OT, so I suppose the thread has to be moved ...

OK,
it works as long as you succeed to connect (even to an idle instance): tested with a "shutting down" oracle instance and a regular user connection and it doesn't work (note that if you're sysdba/sysoper it will work, they are able to connect anyway):

as sysdba

Code:
$ printf "whenever sqlerror exit 42\n\
>  select null from dba_tables;\n" \
>  | sqlplus -s / as sysdba ; \
>  printf "Exit status is: $?\n"
 select null from dba_tables
*
ERROR at line 1:
ORA-01012: not logged on


Exit status is: 42

as regular user

Code:
$ printf "whenever sqlerror exit 42\n\
>  select null from dba_tables;\n" \
>  | sqlplus -s test/test; \
>  printf "Exit status is: $?\n"
ERROR:
ORA-01090: shutdown in progress - connection is not permitted


SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
where <logon>  ::= <username>[/<password>][@<connect_identifier>] | /
SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
where <logon>  ::= <username>[/<password>][@<connect_identifier>] | /
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
Exit status is: 1


Anyway, you get an exit status != 0, so you can handle it via script.
Of course, as far as you don't use it in this way:

Code:
[oracle@ecq007: ~]$ printf "conn test/test\nwhenever sqlerror exit 42\n\
>  select null from dba_tables;\n" \
>  | sqlplus -s /nolog; \
>  printf "Exit status is: $?\n"
ERROR:
ORA-01090: shutdown in progress - connection is not permitted


SP2-0640: Not connected
Exit status is: 0


Regards
Dimitre

Last edited by radoulov; 04-18-2007 at 08:32 AM.. Reason: errata corrige
# 11  
Old 04-19-2007
Lightbulb

Thanks a lot for your sincere support radoulov, Smilie

My main question was, what could be the exact reason for not getting exit status '1' in my first example and why did I get exit '1' for my second example.
I only need to know the differences between those two. Smilie

In this regard, any help would be great help for me.

With Regards and Cheers~~
Mysore Ganapati.
# 12  
Old 04-19-2007
Quote:
Originally Posted by ganapati
[...]
My main question was, what could be the exact reason for not getting exit status '1' in my first example and why did I get exit '1' for my second example.
I only need to know the differences between those two. Smilie
[...]
Don't know, I cannot reproduce your first case (I'm getting exit status 1).

Could you post the content of "$rmia_upd"?
# 13  
Old 04-19-2007
rmia0001.up1 is as below:

WHENEVER SQLERROR EXIT FAILURE

update emp set ename='ganap'
where enum=10001 ;
/
EXIT SUCCESS

Regards,
Ganapati.
# 14  
Old 04-19-2007
Cannot reproduce it:

Code:
$ cat script 
#!/bin/ksh -x

sqlplus -s test/test <<!
@rmia_upd.sql
!

if [ $? -ne 0 ]
then
echo JOB Errored
exit 1
fi

$ cat rmia_upd.sql 
WHENEVER SQLERROR EXIT FAILURE

select null from dual;

EXIT SUCCESS
$ ./script 
+ sqlplus -s test/test
+ << ! 
ERROR:
ORA-01033: ORACLE initialization or shutdown in progress


SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
where <logon>  ::= <username>[/<password>][@<connect_identifier>] | /
ERROR:
ORA-01017: invalid username/password; logon denied


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
+ [ 1 -ne 0 ]
+ echo JOB Errored
JOB Errored
+ exit 1


Are you sure it's the right log? It's strange that the command appears as

Code:
+ sqlplus -s / @/opt/tuxedo/lokesha/rmia0001.up1

and not as

Code:
+ sqlplus -s your_user/your_pass
+ << ! 
...

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Shutdown Oracle DB on SunOS Cluster

Hi, I've this Oracle database version: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production Oracle is install in a SunOS DBSERVER1 5.11 11.2 sun4v sparc sun4v cluster (Not RAC environment) DBSERVER1 is node active and DBSERVER2 is node inactive ... (4 Replies)
Discussion started by: db_senior
4 Replies

2. Shell Programming and Scripting

Capturing Oracle SQL Error Codes

My issue pertains to earlier posts like exit unix script after sqlerror in procedure - dBforums SQLPLUS Error Capturing | Unix Linux Forums | Shell Programming and Scripting We are executing PL/SQL blocks from shell scripts using SQLPLUS. The error code has to be captured into a logfile that... (3 Replies)
Discussion started by: jerome_rajan
3 Replies

3. Shell Programming and Scripting

Help required for Oracle database shutdown script conversion from shell to perl

Please tell me how to convert below program from shell script to perl. Same commands need to use in shutdown, just need program help for startup. export ORACLE_BASE=/home/oracle1 lsnrctl start lndb1 sqlplus '/ as sysdba' startup; (2 Replies)
Discussion started by: learnbash
2 Replies

4. Programming

Problem on capturing system Shutdown

I am having exactly the same problem with https://www.unix.com/programming/129264-application-cleanup-during-linux-shutdown.html but the thread is old and closed. The only difference is that I use sigaction() instead of signal(), which is recommended, as far as I know. This is my code: ... (9 Replies)
Discussion started by: hakermania
9 Replies

5. Shell Programming and Scripting

SQLPLUS Error Capturing

This is my .sh file sqlplus -s my_user/my_pswd@mydb @my_sql.sql ret_code=$? if then echo "return code is $ret_code " echo "Failed" else echo "return code is $ret_code " echo "Success" fi ===================================================== and my_sql.sql is whenever... (4 Replies)
Discussion started by: emailsafath2011
4 Replies

6. Web Development

Tomcat shutdown error

not sure if this is the right forum but im having problem with tomcat restart. i have a regular user that when he login it will go directly to a menu options (a. stop tomcat, start tomcat,). if he selects start it would should show that tomcat has been restarted. if the user press X, he will... (2 Replies)
Discussion started by: lhareigh890
2 Replies

7. Shell Programming and Scripting

Oracle DB Start shutdown scripts

Hi, We have a requirement wherein we do not want to share the Oracle DB sys and system passwords to be shared with the support desk. But they will be responsible for starting/shuting down the Database. Is it possible to write a shell script which will read the sys and system passwords from a... (0 Replies)
Discussion started by: narayanv
0 Replies

8. UNIX for Dummies Questions & Answers

Script to force Oracle database shutdown when shutdown immediate does not work

I have Oracle 9i R2 on AIX 5.2. My Database is running in shared server mode (MTS). Sometimes when I shutdown the database it shutsdown cleanly in 4-5 mints and sometimes it takes good 15-20 minutes and then I get some ora-600 errors and only way to shutdown is by opening another session and... (7 Replies)
Discussion started by: aixhp
7 Replies

9. UNIX for Advanced & Expert Users

Capturing failed FTP error

Hi All, Please check the below ftp related job, which is deleting the files from remote host. Problem is it is not capturing the ftp failure error, and the exit status is still '0' eventhough the deletable files are not present in remote location OR ftp credential are incorrect. ... (5 Replies)
Discussion started by: ganapati
5 Replies

10. UNIX for Dummies Questions & Answers

capturing oracle procedure out param value

I have a procedure with an out parameter, I want to use this value in a shell script, I've done this in perl before but they want this to be a ksh script. what is the syntax to do this. this was my first thought; #!/usr/bin/ksh sqlplus -s scott/tiger@db << EOF ... (1 Reply)
Discussion started by: edog
1 Replies
Login or Register to Ask a Question