Session Wide LockingSession wide locking is based on the principle that the Lock() method sets the current lock mode. When locks are activated, every record read from all active tables of all active databases associated with the session are automatically locked with the current lock mode. // start locking // ASession is a CTSession object try {
ASession.Lock(CTLOCK_WRITE_BLOCK); } catch (CTException &err) {
printf(“Session lock failed with error %d\n”, err.GetErrorCode()); } Unlock() releases all locks acquired since the last Lock() call and clears the current lock mode. IsLockActive() indicates if a session wide lock mode is set. GetLockMode() retrieves the current session wide lock mode. If no session wide locks are active, GetLockMode() returns CTLOCK_FREE. // unlock if locks are active // ARecord is a CTRecord object try {
if (ARecord.GetLockMode() != CTLOCK_FREE) {
ARecord.Unlock(); } } catch (CTException &err) {
printf(“Unlock failed with code %d\n”, err.GetErrorCode()); } Please refer “Date Integrity” in c-tree Plus Programmer’s Reference Guide for a detailed description of transaction processing and locking. |
|||