Re: Connections
Posted in 1997
>From: Johannes Plassmann <plassmann.pad@sni.de> >Date: Thu, 10 Jul 1997 09:05:43 +0200 >X-Informix-List-Id: <news.40292> > >I have a question concerning connections (CONNECT to, DISCONNECT from >commands). During program execution we set a connection to a database >server through (e.g. CONNECT to '@soc20_1'). In other parts of the >program (running in a shared library, used by several instances of >different programs), we would like to know which connection is currently >in use. So my question: Is there a possibility to retrieve the current >active connection (via some kind of GET CONNECTION command)? I'm using 7.23.UC1 ESQL/C, and the following code prints: conn name = <conn1> The 7.20 Informix Guide to SQL: Syntax Volume 1 on p1-329 refers to CONNECTION_ALIAS but on p1-334 refers (correctly) to CONNECTION_NAME. It also discusses when the value changes. I did a little more extensive testing, using a prepared statement, etc, and it always seemed to work. I didn't double check what happens with multiple connections in use, nor what is returned when you connect to the default connection... Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> PS: I decline to respond to messages with anti-spam in the return path. #include <stdio.h> int main() { EXEC SQL BEGIN DECLARE SECTION; varchar buffer[256]; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER ERROR STOP; EXEC SQL CONNECT TO "stores@anubis_53" AS 'conn1'; EXEC SQL GET DIAGNOSTICS EXCEPTION 1 :buffer = CONNECTION_NAME; printf("conn name = <%s>\\n", buffer); return(0); }