Example 1: In a C program, connect to the application server TOROLAB.
EXEC SQL CONNECT TO TOROLAB;
Example 2: In a C program, connect to an application server whose name is stored in the variable APP_SERVER (VARCHAR(18)). Following a successful connection, copy the product identifier of the application server to the variable PRODUCT.
void main () { char product[9] = " "; EXEC SQL BEGIN DECLARE SECTION; char APP_SERVER[19]; char username[11]; char userpass[129]; EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE SQLCA; strcpy(APP_SERVER,"TOROLAB"); strcpy(username,"JOE"); strcpy(userpass,"XYZ1"; EXEC SQL CONNECT TO :APP_SERVER USER :username USING :userpass; if (strncmp(SQLSTATE, "00000", 5) ) { EXEC SQL GET DIAGNOSTICS CONDITION 1 product = DB2_PRODUCT_ID; } ... return; }
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.