CTBRESINFO

Description

Returns result set information.

Syntax

COPY CTPUBLIC.
01 COMMAND        PIC S9(9) COMP SYNC.
01 RETCODE        PIC S9(9) COMP SYNC.
01 RESULT-TYP     PIC S9(9) COMP SYNC.
01 BUFFER         PIC S9(9)
01 BUFFER-LEN     PIC S9(9) COMP SYNC.
01 OUTLEN         PIC S9(9) COMP SYNC.
CALL 'CTBRESIN' USING 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 “Return value,” 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.

This argument is typically:

	 01 BUFFER	   PIC S9(9) COMP SYNC.
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 SYCTSAA5 in Appendix A, “Sample Language Requests.”

       *========================================================
       *==                                                    ==
       *== Subroutine to process result rows                  ==
       *==                                                    ==
       *========================================================
         	  RESULT-ROW-PROCESSING.
  
            CALL 'CTBRESIN' USING CSL-CMD-HANDLE,
                                  CSL-RC,
                                  CS-NUMDATA,
                                  RF-NUMDATA,
                                  RF-NUMDATA-SIZE,
                                  CF-COL-LEN.
  
            IF CSL-RC NOT EQUAL CS-SUCCEED
              THEN
                MOVE SPACES TO MSGSTR
                STRING 'CTBRESINFO failed' DELIMITED BY SIZE
                                                       INTO MSGSTR
                PERFORM PRINT-MSG
                PERFORM ALL-DONE
            END-IF.
  
            COMPUTE FF-ROW-NUM = FF-ROW-NUM + 1.
  
       *********************************
       * display number of connections *
       *********************************
  
            MOVE CF-MAXCONNECT   TO OR2-MAXCONNECT.
            MOVE OUTPUT-ROW-STR2 TO RSLTNO(FF-ROW-NUM).
            COMPUTE FF-ROW-NUM = FF-ROW-NUM + 2.
  
       *********************************
       * display the number of columns *
       *********************************
  
            MOVE RF-NUMDATA      TO OR4-NUMDATA.
            MOVE OUTPUT-ROW-STR4 TO RSLTNO(FF-ROW-NUM).
  
            IF RF-NUMDATA NOT EQUAL 2
              THEN
                STRING 'CTBRESINFO returned wrong # of parms' DELIMITED
                                               BY SIZE INTO MSGSTR
                PERFORM PRINT-MSG
                PERFORM ALL-DONE
            END-IF.
  
            COMPUTE FF-ROW-NUM = FF-ROW-NUM + 2.

Usage


Retrieving the command number for the current result set

To determine the number of the command that generated the current result set, call CTBRESINFO with RESULT-TYP as CS-CMD-NUMBER.


Retrieving the number of result data items

To determine the number of result data items in the current result set, call CTBRESINFO with RESULT-TYP as CS-NUMDATA.


Retrieving the number of rows for the current command

To determine the number of rows affected by the current command, call CTBRESINFO with RESULT-TYP as CS-ROW-COUNT.

See also

Related functions