Product Documentation

SQL Operations Guide

Previous Topic

Next Topic

fc_set_blockinglock( )

Sets the blocking lock strategy for FairCom DB SQL queries.

Description

By default, SQL connections block on locks. Situations can arise with mixing SQL operations with existing non-SQL applications. An application may acquire a non-blocking lock, and hold that lock for a length of time, thereby blocking an SQL query which might be expected to return sooner. An "abandoned" lock might indefinitely block the query. To avoid these situation, options are available to change the blocking lock behavior for SQL connections.

Parameters (mode)

mode SMALLINT

Set mode = 1 to enable blocking locks; set mode = 0 to disable blocking locks

A negative mode value enables a blocking lock with a defined timeout value (in seconds) from the absolute value of the parameter.

For example, a value of -2 with a SELECT query times out if it waits on an existing lock for more than 2 seconds.

The scope of the locking behavior is only within the current user session (that is, the current executing SQL thread); it is not global across other connections. Each SQL thread of operation can specify it's own unique locking behavior.

Examples

To disable blocking locks. A mode value of 0 sets the locking mechanism to not wait in case a lock cannot be acquired and the statement fails with error -17042

call fc_set_blockinglock( 0 );

To enable blocking locks. A mode value of 1 sets the locking mechanism to wait on lock indefinitely (default).

call fc_set_blockinglock( 1 );

To block with a 2-second timeout:. A negative mode value enables blocking locks with specified timeout, if the lock cannot be acquired within the timeout it fails with -17042.

call fc_set_blockinglock( -2 );

TOCIndex