[Info-ingres] Embedded SQL - check Ingres is running
Roy Hann
specially at processed.almost.meat
Mon Nov 30 09:53:19 UTC 2015
Mark wrote:
> What's the easiest way to check whether Ingres is running from an
> embedded SQL program? If I run a SELECT statement, say, and Ingres is
> not running then the program will exit and I don't want this. I would
> want to attempt to reconnect when the server is available.
If you are trying to find out if Ingres is shut down when you try
to connect, you need to catch the -38100 error reported in
sqlca.sqlcode), which is how it normally is reported.
for (;;)
{
exec sql connect mydbc;
if (sqlca.sqlcode < 0)
{
printf("Cannot access database.\n");
...do some sort of sleep(?) here...
}
else
break;
}
If you want to check if Ingres is running before you even try to
connect, we'll need to know more. Are you going to connect only to a
local Ingres server? Do you have peer installations? Do you use vnodes?
What is your OS?
You mention a SELECT statement explicitly. I guess that's just a
placeholder; you are thinking about any statement that returns an error
indicating that Ingres went down after you connected to it. You get the
same error as above, so I would probably install an error handler and
check for -38100 there, rather than doing what I showed above.
Roy
More information about the Info-ingres
mailing list