GET CONNECTION (E-SQL)

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.

Syntax

GET CONNECTION connection_name INTO :hvar

Arguments
connection_name
Is a previously opened connection.
hvar
Is the host variable, declared as data type DBPROCESS *. The hvar option is used to store the DB-Library connection pointer. The pointer can then be used with DB-Library function calls.
Remarks

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.

Examples

#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");

}

  

See Also

CONNECT TO

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.