CTBCOMMAND  CTBCONDROP

Chapter 3: Functions

CTBCONALLOC

Description

Allocates a connection handle.

Syntax

%INCLUDE CTPUBLIC;
DCL
     01 CONTEXT         FIXED BIN(31) INIT(0);
     01 RETCODE         FIXED BIN(31) INIT(0);
     01 CONNECTION  FIXED BIN(31) INIT(0);
 
 CALL CTBCONAL (CONTEXT, RETCODE, CONNECTION); 

Parameters

CONTEXT

(I) A context structure. The context structure is defined in the program call CSBCTXALLOC. The context structure corresponds to the IHANDLE in the Open ServerConnect Gateway-Library.

If this value is invalid or nonexistent, CTBCONALLOC fails.

RETCODE

(O) Variable where the result from an executed function returns. Its value is one of the codes listed under “Returns,” in this section.

CONNECTION

(O) Handle for this connection. All subsequent Client-Library calls using this connection must use this same name in their CONNECTION argument. The connection handle corresponds to the TDPROC handle in the Open ServerConnect Gateway-Library.

This is the same value used to define the connection to the Open ClientConnect Connection Table.

In case of error, CTBCONALLOC returns zeroes to this argument.

Returns

CTBCONALLOC returns one of the following values listed in Table 3-7.

Table 3-7: CTBCONALLOC return values

Value

Meaning

CS_SUCCEED (-1)

The routine completed successfully.

CS_FAIL (-2)

The routine failed.

The most common reason for a CTBCONALLOC failure is a lack of adequate memory.

TDS_SOS (-257)

Memory shortage. The mainframe subsystem was unable to allocate enough memory for the control block that CTBCONALLOC was trying to create. The operation failed.

TDS_GWLIB_NO_STORAGE (-17)

Could not get DSA for Gateway-Library.

Examples

Example 1

The following code fragment demonstrates the use of CTBCONALLOC. It is taken from the sample program SYCTSAA4 in Appendix A, “Sample Language Application.”

/*------------------------------------------------------------------*/
/*                                                                  */
/* Subroutine to process input data                                 */
/*                                                                  */
/*------------------------------------------------------------------*/
 PROCESS_INPUT: PROC ;
 
/*------------------------------------------------------------*/
/* allocate a connection to the server                        */
/*------------------------------------------------------------*/
 
         CSL_CON_HANDLE = 0 ;
 
         CALL CTBCONAL( CSL_CTX_HANDLE,
                        CSL_RC,
                        CSL_CON_HANDLE ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR       = 'CTBCONALLOC failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;
 	/*------------------------------------------------------------*/
 	/* alter properties of the connection for user-id             */
 	/*------------------------------------------------------------*/
         CALL CTBCONPR( CSL_CON_HANDLE,
                        CSL_RC,
                        CS_SET,
                        CS_USERNAME,
                        PF_USER,
                        PF_USER_SIZE,
                        CS_FALSE,
                        OUTLEN ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR = 'CTBCONPROPS for user-id failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;
 
 /*------------------------------------------------------------*/
 /* alter properties of the connection for password            */
 /*------------------------------------------------------------*/
 
         CALL CTBCONPR( CSL_CON_HANDLE,
                        CSL_RC,
                        CS_SET,
                        CS_PASSWORD,
                        PF_PWD,
                        PF_PWD_SIZE,
                        CS_FALSE,
                        OUTLEN ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR = 'CTBCONPROPS for password failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;
 
 /*------------------------------------------------------------*/
 /* alter properties of the connection for transaction         */
 /*------------------------------------------------------------*/
 
         CALL CTBCONPR( CSL_CON_HANDLE,
                        CSL_RC,
                        CS_SET,
                        CS_TRANSACTION_NAME,
                        PF_TRAN,
                        PF_TRANL,
                        CS_FALSE,
                        OUTLEN ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR = 'CTBCONPROPS for transaction failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;
 
 /*------------------------------------------------------------*/
 /* alter properties of the connection for Network driver      */
 /*------------------------------------------------------------*/
 
         SELECT;
           WHEN (PF_NETDRV = '        ')
                 NETDRIVER = CS_LU62 ;
           WHEN (PF_NETDRV = 'LU62' | PF_NETDRV = 'lu62')
                 NETDRIVER = CS_LU62 ;
           WHEN (PF_NETDRV = 'IBMTCPIP' | PF_NETDRV = 'ibmtcpip')
                 NETDRIVER = CS_TCPIP ;
           WHEN (PF_NETDRV = 'INTERLIN' | PF_NETDRV = 'interlin')
                 NETDRIVER = CS_INTERLINK ;
           WHEN (PF_NETDRV = 'CPIC' | PF_NETDRV = 'cpic')
                 NETDRIVER = CS_NCPIC ;
           OTHERWISE
             DO;
                 MSGSTR = 'Invalid Network driver entered';
                 NO_ERRORS_SW = FALSE ;
                 CALL ERROR_OUT;
                 CALL ALL_DONE ;
             END;
         END;
 
         CALL CTBCONPR( CSL_CON_HANDLE,
                        CSL_RC,
                        CS_SET,
                        CS_NET_DRIVER,
                        NETDRIVER,
                        CS_UNUSED,
                        CS_FALSE,
                        OUTLEN ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR = 'CTBCONPROPS for Network driver failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;
 
 /*------------------------------------------------------------*/
 /* setup retrieval of All Messages                            */
 /*------------------------------------------------------------*/
 
         CALL CTBDIAG( CSL_CON_HANDLE,
                       CSL_RC,
                       CS_UNUSED,
                       CS_INIT,
                       CS_ALLMSG_TYPE,
                       CS_UNUSED,
                       CS_UNUSED ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR = 'CTBDIAG CS_INIT failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;
 
 /*------------------------------------------------------------*/
 /* set the upper limit of number of messages                  */
 /*------------------------------------------------------------*/
 
         PF_MSGLIMIT = 5 ;
 
         CALL CTBDIAG( CSL_CON_HANDLE,
                       CSL_RC,
                       CS_UNUSED,
                       CS_MSGLIMIT,
                       CS_ALLMSG_TYPE,
                       CS_UNUSED,
                       PF_MSGLIMIT ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR = 'CTBDIAG CS_MSGLIMIT failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;
 
 /*------------------------------------------------------------*/
 /* open connection to the server or CICS region               */
 /*------------------------------------------------------------*/
 
         CALL CTBCONNE( CSL_CON_HANDLE,
                        CSL_RC,
                        PF_SERVER,
                        PF_SERVER_SIZE,
                        CS_FALSE ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR = 'CTBCONNECT failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;
 
 /*------------------------------------------------------------*/
 /* invokes SEND_COMMAND routine                               */
 /*------------------------------------------------------------*/
         IF NO_ERRORS_SW
           THEN
             CALL SEND_COMMAND ;

Usage

See also

Related functions





Copyright © 2005. Sybase Inc. All rights reserved. CTBCONDROP

View this book as PDF