srv_paramlen (Extended Stored Procedure API)

Applies to: SQL Server

Important

This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use CLR integration instead.

Returns the data length of a remote stored procedure call parameter. This function has been superseded by the srv_paraminfo function.

Syntax

  
int srv_paramlen (  
SRV_PROC *  
srvproc  
,  
int  
n   
);  

Arguments

srvproc
Is a pointer to the SRV_PROC structure that is the handle for a particular client connection (in this case, the handle that received the remote stored procedure call). The structure contains information that the Extended Stored Procedure API library uses to manage communication and data between the application and the client.

n
Indicates the number of the parameter. The first parameter is 1.

Returns

The actual length, in bytes, of the parameter data. If there is no nth parameter or there is no remote stored procedure, it returns -1. If the nth parameter is NULL, it returns 0.

This function returns the following values, if the parameter is one of the following Microsoft SQL Server 2005 (9.x) system data types.

New data types Input data length
BITN NULL: 1

ZERO: 1

>=255: N/A

<255: N/A
BIGVARCHAR NULL: 0

ZERO: 1

>=255: 255

<255: actual len
BIGCHAR NULL: 0

ZERO: 255

>=255: 255

<255: 255
BIGBINARY NULL: 0

ZERO: 255

>=255: 255

<255: 255
BIGVARBINARY NULL: 0

ZERO: 1

>=255: 255

<255: actual len
NCHAR NULL: 0

ZERO: 255

>=255: 255

<255: 255
NVARCHAR NULL: 0

ZERO: 1

>=255: 255

<255: actual len
NTEXT NULL: -1

ZERO: -1

>=255: -1

<255: -1

* actual len = Length of multibyte character string (cch)

Remarks

Each remote stored procedure parameter has an actual and a maximum data length. For standard fixed-length data types that do not allow null values, the actual and maximum lengths are the same. For variable-length data types, the lengths can vary. For example, a parameter declared as varchar(30) can have data that is only 10 bytes long. The parameter's actual length is 10 and its maximum length is 30. The srv_paramlen function gets the actual data length, in bytes, of a remote stored procedure. To obtain the maximum data length of a parameter, use srv_parammaxlen.

When a remote stored procedure call is made with parameters, the parameters can be passed either by name or by position (unnamed). If the remote stored procedure call is made with some parameters passed by name and some passed by position, an error occurs. The SRV_RPC handler is still called, but it appears as if there were no parameters and srv_rpcparams returns 0.

Important

You should thoroughly review the source code of extended stored procedures, and you should test the compiled DLLs before you install them on a production server. For information about security review and testing, see this Microsoft Web site.

See Also

srv_paraminfo (Extended Stored Procedure API)
srv_rpcparams (Extended Stored Procedure API)