[Info-ingres] Embedded SQL - check Ingres is running

Mark i at dontgetlotsofspamanymore.net
Mon Nov 30 10:22:05 UTC 2015


On Mon, 30 Nov 2015 09:53:19 +0000 (UTC), Roy Hann
<specially at processed.almost.meat> wrote:

>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. 

No.  After the program has started (and run some SQL statements) then
Ingres server may have been stopped (and possibly restarted) before
the program runs another SQL statement.  If the Database server has
been restarted I don;t want this to fail.

>Are you going to connect only to a
>local Ingres server? 

Yes.

>Do you have peer installations? Do you use vnodes?
>What is your OS?

Linux.

>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. 

Yes.

>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.

I'll do this, thanks.




More information about the Info-ingres mailing list