srv_getbindtoken

Obtains a bind token so that 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 );

where

srvproc
Is a pointer to the SRV_PROC structure that is the handle for a particular client connection. The srvproc parameter contains the information that the Open Data Services Library uses to manage communication and data between the application and the 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 the extended stored procedure so that they share the same transaction lock space
  1. The extended stored procedure calls srv_getbindtoken. This uses the existing bind token of the calling session if the calling session is already bound to a bind token. If the calling session is not already bound, srv_getbindtoken creates a new bind token and binds the calling 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 can have access to a shared connection at a time. If one session is currently executing a statement in 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 will be returned to the conflicting session indicating that the connection is in use and that the session should retry later.

See Also

sp_bindsession, sp_getbindtoken