ct_compute_info

Description

Retrieve compute result information.

Syntax

CS_RETCODE ct_compute_info(cmd, type, colnum, buffer,
                 buflen, outlen)
 CS_COMMAND      *cmd;
 CS_INT                    type;
 CS_INT                   colnum;
 CS_VOID                *buffer;
 CS_INT                    buflen;
 CS_INT                   *outlen;

Parameters

cmd

A pointer to the CS_COMMAND structure managing a client/server command.

type

The type of information to return. For a list of the symbolic values for type, see Table 3-10.

colnum

The number of the compute column of interest, as it appears in the compute row result set. Compute columns appear in the order in which they are listed in the compute clause of a select statement. The first column is number 1, the second is number 2, and so forth.

buffer

A pointer to the space in which ct_compute_info will place the requested information.

If buflen indicates that *buffer is not large enough to hold the requested information, ct_compute_info returns CS_FAIL.

buflen

The length, in bytes, of the *buffer data space or CS_UNUSED if *buffer represents a fixed-length or symbolic value.

outlen

A pointer to an integer variable.

Returns

ct_compute_info returns the following values:

Return value

Meaning

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

CS_BUSY

An asynchronous operation is already pending for this connection. See “Asynchronous programming”.

Examples

Example 1

Assume that the following command has been executed:

select dept, name, year, sales from employee 
           order by dept, name, year 
           compute count(name) by dept, name
  1. The call:

    CS_INT      mybuffer;
    
    ct_compute_info(cmd, CS_BYLIST_LEN, CS_UNUSED,
    
            &mybuffer, CS_UNUSED, CS_UNUSED);
    

    sets mybuffer to 2, because there are two items in the bylist.

  2. The call:

    CS_SMALLINT    mybuffer[2];
    
     CS_INT         outlength;
    
    ct_compute_info(cmd, CS_COMP_BYLIST, CS_UNUSED,
    
             mybuffer, sizeof(mybuffer), &outlength)
    

    copies the CS_SMALLINT values 1 and 2 into mybuffer[0] and mybuffer[1] to indicate that the bylist is composed of columns 1 and 2 from the select list.

  3. The call:

    CS_INT      mybuffer;
    
    ct_compute_info(cmd, CS_COMP_COLID, 1, &mybuffer,
    
            CS_UNUSED,NULL);
    

    sets mybuffer to 2, since name is the second column in the select list.

  4. The call:

    CS_INT     mybuffer;
    
    ct_compute_info(cmd, CS_COMP_ID, CS_UNUSED,
    
             &mybuffer, CS_UNUSED, NULL);
    

    sets mybuffer to 1 because there is only a single compute clause in the select statement.

  5. The call:

    CS_INT    mybuffer;
    
    ct_compute_info(cmd, CS_COMP_OP, 1, &mybuffer,
    
            CS_UNUSED, NULL);
    

    sets mybuffer to the symbolic value CS_OP_COUNT, since the aggregate operator for the first compute column is a count.

Usage

Table 3-10 summarizes ct_compute_info usage.

Table 3-10: Summary of ct_compute_info parameters

Value of type

Value of colnum

Information retrieved

*buffer is set to

*outlen is set to

CS_BYLIST_LEN

CS_UNUSED

The number of elements in the bylist array

An integer valu.

sizeof(CS_INT)

CS_COMP_BYLIST

CS_UNUSED

An array containing the bylist that produced this compute row

An array of CS_SMALLINT values

The length of the array, in bytes

CS_COMP_COLID

The column number of the compute column

The select-list column ID of the column from which the compute column derives

An integer value

sizeof(CS_INT)

CS_COMP_ID

CS_UNUSED

The compute ID for the current compute row

An integer value

sizeof(CS_INT)

CS_COMP_OP

The column number of the compute column

The aggregate operator type for the compute column

One of the following symbolic values:

CS_OP_SUM CS_OP_AVG CS_OP_COUNT CS_OP_MIN CS_OP_MAX

sizeof(CS_INT)


The bylist for a compute row


The select-list column ID for a compute column


The compute ID for a compute row


The aggregate operator for a particular compute row column

See also

ct_bind, ct_describe, ct_res_info, ct_results