Re: Q: How to check if database is up using Pro*C
Date: 1996/11/07
Message-ID: <55tbj2$itv_at_panix3.panix.com>#1/1
In <55t2bj$ine_at_linet01.li.net> gsa_at_li.net (Gary Assa) writes:
>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.
Deja vu. Please post your questions only once.
You mean (from my previous posting):
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR db_string[31];
VARCHAR username[31];
VARCHAR password[31];
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE sqlca;
#define Ostrcpyin(ora,str) { strcpy(ora.arr,str); ora.len=strlen(str); } #define CONNECTSTR "P:" #define USER "scott" #define PASS "tiger"
int database_is_up()
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
/* Connect to remote database */
Ostrcpyin(db_string,CONNECTSTR); Ostrcpyin(username,USER); Ostrcpyin(password,PASS);
EXEC SQL CONNECT :username IDENTIFIED BY :password USING :db_string; return (sqlca.sqlcode == 0L);
}
?
Disconnection from the database prior to program termination is left as an exercise for the student.
Andy
-- Andrew Finkenstadt, The Printing House Ltd, Also a GEnie Sysop "By the time they had diminished from 50 to 8, the other dwarves began to suspect 'Hungry' ..." -- Gary Larson, "The Far Side"Received on Thu Nov 07 1996 - 00:00:00 CET