CTBCOMMAND

Description

Initiates a language request or remote procedure call (RPC).

Syntax

%INCLUDE CTPUBLIC;
DCL
     01 COMMAND         FIXED BIN(31) INIT(0);
     01 RETCODE          FIXED BIN(31) INIT(0);
     01 REQTYPE          FIXED BIN(31) INIT(0);
     01 BUFFER type;
     01 BUFFER_LEN    FIXED BIN(31);
     01 OPTION             FIXED BIN(31);
 
CALL CTBCOMMA (COMMAND, RETCODE, REQTYPE, BUFFER, BUFFER_LEN, OPTION); 

Parameters

COMMAND

(I) Handle for this client/server operation. This handle is defined in the associated CTBCMDALLOC call. The command handle corresponds to the TDPROC handle in the Open ServerConnect Gateway-Library.

RETCODE

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

REQTYPE

(I) Type of request to initiate. The following symbolic values are legal for REQTYPE:

When REQTYPE is

CTBCOMMAND initiates

BUFFER contains

CS_LANG_CMD (148)

A language request.

The text of the language request.

CS_RPC_CMD (149)

A remote procedure call.

The name of the remote procedure.

BUFFER

(I) Variable (buffer) that contains the language request or RPC name.

This argument is typically one of the following datatypes:

 01 BUFFER  FIXED BIN(n);
 01 BUFFER  CHAR(n);
BUFFER_LEN

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

If the value in the buffer is a fixed-length or symbolic value, assign BUFFER_LEN a value of CS_UNUSED.

OPTION

Option associated with this request, if any.

Currently, only RPCs take options. For language requests, assign OPTION a value of CS_UNUSED.

The following symbolic values are legal for OPTION when REQTYPE is CS_RPC_CMD:

Value

Meaning

CS_RECOMPILE (188)

Recompile the stored procedure before executing.

CS_NORECOMPILE (189)

Do not recompile the stored procedure before executing.

CS_UNUSED (-99999)

No options are assigned.

Returns

CTBCOMMAND returns one of the following values listed in Table 3-6.

Table 3-6: CTBCOMMAND return values

Value

Meaning

CS_SUCCEED (-1)

The routine completed successfully.

CS_FAIL (-2)

The routine failed.

TDS_CONNECTION_TERMINATED (-4997)

The connection is not active.

TDS_INVALID_PARAMETER (-4)

A parameter contains an illegal value.

TDS_WRONG_STATE (-6)

Program is in the wrong communication state to issue this call.

Examples

Example 1

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

/*------------------------------------------------------------*/
/* allocate a command handle                                  */
/*------------------------------------------------------------*/

         CALL CTBCMDAL( CSL_CON_HANDLE,
                        CSL_RC,
                        CSL_CMD_HANDLE ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR       = 'CTBCMDALLOC failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;

/*------------------------------------------------------------*/
/* prepare the language request                               */
/*------------------------------------------------------------*/
 
         PF_STRLEN = STG(CF_LANG2 ) ;
 
         CALL CTBCOMMA( CSL_CMD_HANDLE,
                        CSL_RC,
                        CS_LANG_CMD,
                        CF_LANG2,
                        PF_STRLEN,
                        CS_UNUSED ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR       = 'CTBCOMMAND failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;
 
 /*------------------------------------------------------------*/
 /* send the language request                                  */
 /*------------------------------------------------------------*/
 
         CALL CTBSEND( CSL_CMD_HANDLE,
                       CSL_RC ) ;
 
         IF CSL_RC ^= CS_SUCCEED THEN
         DO ;
           MSGSTR       = 'CTBSEND failed' ;
           NO_ERRORS_SW = FALSE ;
           CALL ERROR_OUT;
           CALL ALL_DONE ;
         END ;
 
 END SEND_COMMAND ;

Usage


Language requests


RPCs

See also

Related functions:

Related topics: