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

Home -> Community -> Usenet -> c.d.o.server -> Re: Q: How to check if database is up using Pro*C

Re: Q: How to check if database is up using Pro*C

From: M.Rapier <M.Rapier_at_shef.ac.uk>
Date: 1996/11/08
Message-ID: <55v1tq$91n@bignews.shef.ac.uk>#1/1

In article <55t2d2$iob_at_linet01.li.net>, gsa_at_li.net says...

>I am writing a Pro*C program that executes from a web page that has many
>user enterable fields. However if the database is down (due to backups
>or some other reason) I don't want to make the people spend time entering
>all these fields then have "ORACLE ERROR, etc" pop up. How can I quickly
>check that the database is up before jumping to the web page??
>
>I need the C code, not an idea.

Do you mean something like this...

/*
uname is the username
pwd is the password

sqlerror() is an error handling function that uses sqlca etc.

....
*/

strcpy (uid.arr,uname);
uid.len = strlen(uid.arr);
strcpy (pwd.arr,pwd);
pwd.len = strlen(pwd.arr);

printf(" Oracle...");

EXEC SQL WHENEVER SQLERROR DO sqlerror(); EXEC SQL CONNECT :uid IDENTIFIED BY :pwd; printf("connected...");
EXEC SQL COMMIT WORK RELEASE; ....

It just connects to the database to check if there is an error. Of course, there is no guarantee that the database _wont_ go away while your users are filling in their form.

Why not use the Oracle Webserver (or at least the Web Request Broker along with your favourite Web Sever) for this sort of thing, it is free after all.

Cheers.
Martin. Received on Fri Nov 08 1996 - 00:00:00 CST

Original text of this message

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