ct_res_info

Description

Returns result set information.

Syntax

CS_RETCODE ct_res_info(command, result_type, buffer,
                        buf_len, outlen); 
CS_COMMAND    *command;
CS_INT        result_type;
CS_BYTE       *buffer;
CS_INT        buf_len;
CS_INT        *outlen;

Parameters

command

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

result_type

(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 ct_res_info returns the requested information. At present, this is always an integer value.

buf_len

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

If the returned value is longer than buf_len, ct_res_info 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 ct_res_info returns the length of the information being retrieved.

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

Returns

ct_res_info returns one of the following values:

Value

Meaning

CS_SUCCEED (-1)

Results are available for processing.

CS_FAIL (-2)

The routine failed.

ct_res_info returns CS_FAIL if the requested information is larger than buf_len bytes.

Examples

Example 1

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

  	/********************************************************************/
  	/*                                                                  */
  	/* Subroutine to process result rows                                */
  	/*                                                                  */
  	/********************************************************************/
  	void   result_row_processing ()
	{
   	CS_INT        rc;
   	CS_INT        col_len;
   	CS_INT        &numcol;
   	CS_INT        parm_cnt;
   	char          msg1[40] = "The maximum number of connections is   ";
   	char          msg2[25] = "The number of columns is ";
   	char          wrk_str [4];
   	char          period = '.';
  /*------------------------------------------------------------*/
  /* 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().                               */
  /*------------------------------------------------------------*/
rc = ct_res_info(cmd,CS_NUMDATA,&&numcol,
         sizeof(&numcol),&col_len);
if (rc != CS_SUCCEED)
         {
            strncpy (msgstr, "CT_RES_INFO failed", msg_size);
            no_errors_sw = FALSE ;
            error_out (rc);
         }
  /*------------------------------------------------------------*/
  /* display the number of connections                          */
  /*------------------------------------------------------------*/
          row_num = row_num + 1;
          strncpy (RS[row_num].rsltno, msg1, msg_size);
cvtleft  = 4;           /* Digits to the left */
          cvtright = 0;           /* Digits to the right */
          SYCVTD(maxconnect, wrk_str,
                  cvtleft, cvtright, cvtwork, cvtdbl, CS_TRUE);
strncat (RS[row_num].rsltno, wrk_str, 4);
          row_num = row_num + 2;
  /*------------------------------------------------------------*/
  /* display the number of columns                              */
  /*------------------------------------------------------------*/
strncpy (RS[row_num].rsltno, msg2, sizeof(msg2));
          cvtleft  = 4;           /* Digits to the left */
          cvtright = 0;           /* Digits to the right */
          SYCVTD(&numcol, wrk_str,
                  cvtleft, cvtright, cvtwork, cvtdbl, CS_TRUE);
strncat (RS[row_num].rsltno, wrk_str, 4);
          row_num = row_num + 2;
if (&numcol != 2)
          {
            strncpy (msgstr, "CT_RES_INFO returned wrong # of parms",
                     msg_size);
            no_errors_sw = FALSE ;
            error_out (rc);
          }

Usage

The following arguments listed in Table 3-14 are returned to result_type after ct_results indicates that results are present.

Table 3-14: Summary of arguments

RESULT_TYP

ct_res_info 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.


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

See also

Related functions

Related topics