srv_getbindtoken

Extended Stored Procedure Programming

Extended Stored Procedure Programming

srv_getbindtoken

Obtains a bind token so an extended stored procedure session can share a common transaction lock space with the client session that invoked the extended stored procedure, instead of opening a separate session.

Syntax

int srv_getbindtoken ( SRV_PROC* srvproc,
char* bindtoken );

Arguments

srvproc

Is a pointer to the SRV_PROC structure that is the handle for a particular client connection. The srvproc parameter contains information that the ODS Library uses to manage communication and data between the application and client.

bindtoken

Is a pointer to a buffer where the bind token will be copied. The bind token is represented as a null-terminated string. The buffer you specify should be 255 bytes in length.

Returns

SUCCEED or FAIL.

Remarks

To bind an extended stored procedure session to the client session that called it so they share the same transaction lock space

  1. The extended stored procedure calls svr_getbindtoken. This uses the existing bind token of the client session if the session is already bound. If not, srv_getbindtoken creates a new bind token and binds the client session to the token. srv_getbindtoken then returns the bind token in the bindtoken parameter.

  2. The extended stored procedure uses the bind token with sp_bindsession to bind an extended stored procedure session to the client session. Multiple extended stored procedure sessions can be bound to a client session.

  3. A bound session is unbound when the external stored procedure returns or when sp_bindsession is called with an empty string.

    Note  Only one bound session at a time can have access to a shared connection. If one session is currently executing a statement at the server or has results pending from the server, no other sessions sharing the same bound connection can gain access to the server until the current session has finished executing the current statement. If a session attempts to gain access to the connection while the server is busy, an error is returned to the conflicting session indicating the connection is in use and the session should retry later.

See Also

sp_bindsession

sp_getbindtoken