Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: PRO*C QUESTION:how to detect DB shutdown/crash!!

Re: PRO*C QUESTION:how to detect DB shutdown/crash!!

From: Johan Wegener <xjwegener_at_xpost.xtele.xdk>
Date: Mon, 5 Jul 1999 22:15:42 +0200
Message-ID: <7lr3mv$m6m$1@news.inet.tele.dk>


Joao Barreto Fernandes wrote in message = <377CB421.9D3280FA_at_ssd.alcatel.pt>...
>Hello there.
>
>Sorry if this is not the correct group for posing this question.
>
>How can one detect, in a PRO*C program, that the SGDB has been
>shut down or has crashed? Is it only detected when one tries to run
>a SQL command and gets an exceotion?
>
>Thanks in advance
>Joao

The simplest way is to test the value of sqlca.sqlcode after execting = each SQL statement. This value then contains the present state of the = database. You may encounter several different sqlcodes such as -1089 = Oracle shutdown in progres, -3113 end-of-file on communication channel, =  -3114 not connected to Oracle, and several others.

In case of a crash, however, the calls to Oracle may block and your = program hangs. A relatively simple way of detecting this, is to include = a second thread in your program. Do the main work as usual, but at the = start of your program spawn a simple thread that every other second or = so connects to the database, tests its own sqlca.sqlcode and = disconnects. To my knowledge, the EXECUTE SQL CONNECT ...., won't block. = Thread synchronisation issues are left to you.

If you use win32/NT (you are not indicating which OS you use), you may = query the Service Control Manager as to the state of the Oracle service. =

Cheers,
Johan
-
Johan Wegener
Email: xjwegener_at_xpost.xtele.xdk
NOSPAM: Delete xxxx before replying Received on Mon Jul 05 1999 - 15:15:42 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US