srv_dynamic

Description

Read or respond to a client dynamic SQL command.

Syntax

CS_RETCODE srv_dynamic(spp, cmd, item, bufp,
                          buflen, outlenp)
SRV_PROC       *spp;
CS_INT               cmd;
CS_INT               item;
CS_VOID            *bufp
CS_INT               buflen;
CS_INT              *outlenp

Parameters

spp

A pointer to an internal thread control structure.

cmd

Indicates whether a dynamic command is being read from or sent to a client. Table 3-38 describes the legal values for cmd:

Table 3-38: Values for cmd (srv_dynamic)

Value

Description

CS_SET

srv_dynamic is sending a response to a dynamic command back to a client.

CS_GET

srv_dynamic is reading a dynamic command from a client.

item

Indicates what kind of information is being sent or retrieved. Table 3-39 describes the legal values for item:

Table 3-39: Values for item (srv_dynamic)

Value

Meaning

SRV_DYN_TYPE

The type of dynamic operation being performed.

SRV_DYN_IDLEN

The length of the dynamic statement ID.

SRV_DYN_ID

The dynamic statement ID.

SRV_DYN_STMTLEN

The length of the dynamic statement.

SRV_DYN_STMT

The dynamic statement that is being prepared or executed.

bufp

A pointer to the buffer in which the item value is returned (CS_GET) or set (CS_SET).

buflen

The length, in bytes, of the *bufp buffer. Table 3-40 summarizes the required buffer sizes:

Table 3-40: Required buffer sizes (srv_dynamic)

Value

Required format (size)

SRV_DYN_TYPE

sizeof(CS_INT).

SRV_DYN_IDLEN

sizeof(CS_INT).

SRV_DYN_ID

Varies. Determine length by first calling srv_dynamic with item set to CS_DYN_IDLEN and then allocate buffer size accordingly.

SRV_DYN_STMTLEN

sizeof(CS_INT).

SRV_DYN_STMT

Varies. Determine length by first calling srv_dynamic with item set to CS_DYN_STMTLEN and then allocate buffer size accordingly.

outlenp

A pointer to an integer variable which is set to the actual length of data copied into *bufp when retrieving data from the client (cmd is CS_GET). This argument is not required if cmd is CS_SET.

Returns

Table 3-41: Return values (srv_dynamic)

Returns

To indicate

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Examples

Example 1

#include        <ospublic.h>
/*
 ** Local Prototype
 */
extern CS_RETCODE                ex_srv_dynamic PROTOTYPE((
CS_VOID     *spp,
CS_INT      *optypep
));
/* 
 ** EX_SRV_DYNAMIC
**
**    Example routine to retrieve dynamic operation type from a
 **    client.
**
** Arguments:
**    spp      Thread control structure.
**    optypep  Dynamic operation type.
**
** Returns:
**
**    CS_SUCCEED   Dynamic information was retrieved 
 **                 successfully.
**    CS_FAIL      An error was detected.
 */
CS_RETCODE      ex_srv_dynamic(spp, optypep)
SRV_PROC   *spp;
CS_INT     *optypep;
{
CS_INT     outlen;

    if(srv_dynamic(spp, CS_GET, SRV_DYN_TYPE, optypep,
         sizeof(*optypep), &outlen) == CS_FAIL)
    {
        return(CS_FAIL);
    }
    return(CS_SUCCEED);
}

Usage

See also

srv_bind, srv_descfmt, srv_numparams, srv_xferdata, “Dynamic SQL”