CTBRESINFO

Description

Returns result set information.

Syntax

%INCLUDE CTPUBLIC;
DCL
     01 COMMAND       FIXED BIN(31) INIT(0);
     01 RETCODE        FIXED BIN(31) INIT(0);
     01 RESULT_TYP   FIXED BIN(31);
     01 BUFFER         type;
     01 BUFFER_LEN   FIXED BIN(31);
     01 OUTLEN           FIXED BIN(31);
 
CALL CTBRESIN (COMMAND, RETCODE, RESULT_TYP, BUFFER, BUFFER_LEN, OUTLEN); 

Parameters

COMMAND

(I) Handle for this client/server operation. This handle is defined in the associated CTBCMDALLOC call.

RETCODE

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

RESULT_TYP

(I) Type of information to return. Assign this argument one of the following values:

Value

Meaning

CS_ROW_COUNT (800)

The number of rows affected by the current command.

CS_CMD_NUMBER (801)

The number of the command that generated the current result set.

CS_NUMDATA (803)

The number of items in the current result set.

BUFFER

(O) Variable (“buffer”) where CTBRESINFO returns the requested information. At present, this will always be an integer value.

BUFFER_LEN

(I) Length, in bytes, of the buffer.

If the returned value is longer than BUFFER_LEN, CTBRESINFO sets OUTLEN to the length of the requested information and returns CS_FAIL.

OUTLEN

(O) Length, in bytes, of the retrieved information. OUTLEN is an integer variable where CTBRESINFO returns the length of the information being retrieved.

If the retrieved information is larger than BUFFER_LEN bytes, an application uses the value of OUTLEN to determine how many bytes are needed to hold the information.

Returns

CTBRESINFO returns one of the following values:

Value

Meaning

CS_SUCCEED (-1)

Results are available for processing.

CS_FAIL (-2)

The routine failed.

CTBRESINFO returns CS_FAIL if the requested information is larger than BUFFER_LEN bytes.

Examples

Example 1

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

/*------------------------------------------------------------------*/
/*                                                                  */
/* Subroutine to process result rows                                */
/*                                                                  */
/*------------------------------------------------------------------*/
RESULT_ROW_PROCESSING: PROC ;
 
 /*------------------------------------------------------------*/
 /* We need to bind the data to program variables. We don't    */
 /* care about the indicator variable so we'll pass NULL for   */
 /* that parameter in OC_BIND().                               */
 /*------------------------------------------------------------*/
 
         CALL CTBRESIN( CSL_CMD_HANDLE,
                        CSL_RC,
                        CS_NUMDATA,
                        RF_NUMDATA,
                        STG(RF_NUMDATA),
                        CF_COL_LEN ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR       = 'CTBRESINFO failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE;
         END ;
 
         FF_ROW_NUM = FF_ROW_NUM + 1;
 
 /*------------------------------------------------------------*/
 /* display the number of connections                          */
 /*------------------------------------------------------------*/
 
         OR2_MAXCONNECT     = CF_MAXCONNECT ;
         RSLTNO(FF_ROW_NUM) = OUTPUT_ROW_STR2 ;
         FF_ROW_NUM         = FF_ROW_NUM + 2;

/*------------------------------------------------------------*/
/* display the number of columns                              */
/*------------------------------------------------------------*/
 
         OR4_NUMDATA        = RF_NUMDATA ;
         RSLTNO(FF_ROW_NUM) = OUTPUT_ROW_STR4 ;
 
         IF RF_NUMDATA ^= 2 THEN
         DO ;
           MSGSTR       = 'CTBRESINFO returned wrong # of parms' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE;
         END ;
 
         FF_ROW_NUM = FF_ROW_NUM + 2;
 
 /*------------------------------------------------------------*/
 /* Setup column headings                                      */
 /*------------------------------------------------------------*/
 
         RSLTNO(FF_ROW_NUM) = 'FirstName    EducLvl' ;
         FF_ROW_NUM         = FF_ROW_NUM + 1;
         RSLTNO(FF_ROW_NUM) = '===========  =======' ;
 
         DO PARM_CNT = 1 TO RF_NUMDATA  ;
           CALL BIND_COLUMNS ;
         END ;
 
 END RESULT_ROW_PROCESSING ;

Usage


Retrieving the command number for the current result set


Retrieving the number of result data items


Retrieving the number of rows for the current command

The following arguments listed in Table 3-17 are returned to RESULT_TYP after CTBRESULTS indicates that results are present.

Table 3-17: Summary of arguments (CTBRESINFO)

RESULT_TYP

CTBRESINFO returns

BUFFER value

CS_ROW_COUNT (800)

The number of rows affected by the current command.

An integer value.

CS_CMD_NUMBER (801)

The number of the command that generated the current result set.

An integer value.

CS_NUMDATA (803)

The number of items in the current result set.

An integer value.

See also

Related functions:

Related topics: