dbrpcparam

Description

Add a parameter to a remote procedure call.

Syntax

RETCODE dbrpcparam(dbproc, paramname, status, type,
                 maxlen, datalen, value)
 
DBPROCESS   *dbproc;
char                  *paramname;
BYTE                 status;
int                       type;
DBINT                maxlen;
DBINT                datalen;
BYTE                 *value;

Parameters

dbproc

A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library uses to manage communications and data between the front end and the server.

paramname

A pointer to the name of the parameter to be invoked. This name must begin with the “@” character, which prefixes all stored procedure parameter names. As in the Transact-SQL execute statement, the name is optional. If it is not used, it should be specified as NULL. In that case, the order of the dbrpcparam calls determines the parameter to which each refers.

status

A 1-byte bitmask of RPC-parameter options. So far, the only option available is DBRPCRETURN, which signifies that the application program would like this parameter used as a return parameter.

type

A symbolic constant indicating the datatype of the parameter (for example, SYBINT1, SYBCHAR, and so on). Parameter values should be sent to the server in a datatype that matches the Adaptive Server datatype with which the corresponding stored procedure parameter was defined—see Types for a list of type constants and the corresponding Adaptive Server datatypes.

maxlen

For return parameters, this is the maximum desired byte length for the RPC parameter value returned from the stored procedure. maxlen is relevant only for values whose datatypes are not fixed in length—that is, char, text, binary, and image values. If this parameter does not apply (that is, if the type is a fixed length datatype such as SYBINT2) or if you do not care about restricting the lengths of return parameters, set maxlen to -1. maxlen should also be set to -1 for parameters not designated as return parameters.

datalen

The length, in bytes, of the RPC parameter to pass to the stored procedure. This length should not count any null terminator.

If type is SYBCHAR, SYBVARCHAR, SYBBINARY, SYBVARBINARY, SYBBOUNDARY, or SYBSENSITIVITY, datalen must be specified. Passing datalen as -1 for any of these datatypes results in the DBPROCESS referenced by dbproc being marked as “dead,” or unusable.

If type is a fixed length datatype, for example, SYBINT2, pass datalen as -1.

If the value of the RPC parameter is NULL, pass datalen as 0, even if type is a fixed-length datatype.

value

A pointer to the RPC parameter itself. If datalen is 0, this pointer will be ignored and treated as NULL. Note that DB-Library does not copy *value into its internal buffer space until the application calls dbrpcsend. An application must not write over *value until after it has called dbrpcsend.

The value of type indicates the datatype of *value. See Types for more information. For types that have no C equivalent, such as SYBDATETIME, SYBMONEY, SYBNUMERIC, or SYBDECIMAL, use dbconvert_ps to initialize *value.

NoteAn application must not write over *value until after it has called dbrpcsend to send the remote procedure call to the server. This is a functional change from previous versions of DB-Library.

Returns

SUCCEED or FAIL.

Usage

See also

dbnextrow, dbresults, dbretdata, dbretstatus, dbrpcinit, dbrpcsend, dbsqlok