Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Q: How to check if database is up using Pro*C
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
![]() |
![]() |