The GET CONNECTION statement retrieves the DBPROCESS pointer for the specified connection and stores the pointer in a host variable for use with DB-Library function calls.
GET CONNECTION connection_name INTO :hvar
The GET CONNECTION statement stores the DB-Library DBPROCESS pointer for an ESQL/C connection in a host variable. This is useful if you want to use features or functions that are specific to DB-Library (such as text and image handling functions) in your ESQL/C program.
As with all DB-Library programs, you must first use #define to define the appropriate platform before you include the DB-Library header files Sqlfront.h and Sqldb.h and link to the appropriate DB-Library .lib file.
If you are using a WHENEVER statement in your program, the Embedded SQL keyword sqlerror must not be uppercase to avoid conflict with the DB Library-defined constant SQLERROR.
#define DBNTWIN32
#include <windows.h>
#include <sqlfront.h>
#include <sqldb.h>
.
.
.
EXEC SQL BEGIN DECLARE SECTION;
DBPROCESS* dbproc;
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO gizmo.pubs
AS my_connection
USER sa
EXEC SQL GET CONNECTION my_connection
INTO dbproc;
if (dbproc != NULL)
{
printf("Got DBPROCESS connection, current database is '%Fs'\n",
dbname(dbproc));
}
else
{
printf("ERROR: Getting DBPROCESS connection\n");
}