SqlRpcParam%

Adds a parameter to a stored procedure or a remote stored procedure.

Syntax

SqlRpcParam% ( sqlconn%, paramname$, status%, type%, maxlen&,
datalen&, value$ )

where

sqlconn%
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.
paramname$
Is the name of the parameter to be invoked. This name must begin with the at symbol (@), as do all parameter names within stored procedures. As in the Transact-SQL EXECUTE statement, the name is optional. If the name is not used, it should be specified as an empty string. In that case, the order of the SqlRpcParam% calls determines the parameter to which each call refers.
status%
Is a 1-byte bitmask of parameter options for stored procedures. The only option currently available is SQLRPCRETURN, which signifies that an application designates this parameter as a return parameter. Specify 0 to indicate no options.
type%
Is the datatype of the value$ parameter (such as SQLINT1, SQLCHAR, and so on).
maxlen&
For variable-length return parameters (when type% is SQLCHAR, SQLBINARY, SQLTEXT, or SQLIMAGE), the maximum desired byte length for the value$ parameter returned from a stored procedure.

Set maxlen& to -1 in any of these cases:

Set maxlen to 0 to pass a NULL variable-length parameter value (when type% is SQLCHAR, SQLBINARY, SQLTEXT, or SQLIMAGE) to the stored procedure.

datalen&
For variable-length return parameters (when type% is SQLCHAR, SQLBINARY, SQLTEXT, or SQLIMAGE), datalen& is the actual byte length of the value$ parameter sent to the stored procedure. The byte length should not count any null terminator.

Set datalen& to - 1 for fixed-length parameters (such as when type% is SQLINT4).

Set datalen& to 0 to pass a NULL parameter value (fixed or variable length) to the stored procedure.

value$
Is a string containing the stored procedure parameter itself. DB-Library converts the string to its native datatype. You must use binary strings for binary parameters (when type% is SQLBINARY or SQLIMAGE.)

The following table summarizes the required maxlen& and datalen& values for each type of parameter.
Parameter maxlen& datalen&
Fixed-length - 1 - 1
Variable-length Maximum desired length of return value Length of input value
Fixed-length NULL - 1 0
Variable-length NULL 0 0

When specifying a NULL parameter, the actual contents of value$ is not used, and a NULL parameter is added to the stored procedure.

Returns

SUCCEED or FAIL.

Remarks

After initializing a stored procedure using SqlRpcInit%, you must call SqlRpcParam% once for each parameter of the stored procedure that does not have a default value. You specify default values for stored procedure parameters in the CREATE PROCEDURE statement. For more information about executing stored procedures using DB-Library functions, see "SqlRpcInit%."

See Also

SqlNextRow%, SqlOk%, SqlResults%, SqlRetData$, SqlRetStatus&, SqlRpcInit%, SqlRpcSend%