QMRelease

Top  Previous  Next

 

The QMRelease function releases a record lock. It is analogous to the QMBasic RELEASE statement.

 

 

Format

 

VBQMRelease ByVal FileNo as Integer, ByVal Id as String

 

Cvoid QMRelease(int FileNo, char * Id)

 

ObjSession->Release(FileNo, Id)

 

where

 

FileNois the file number returned by a previous QMOpen() call. If zero, all locks are released.

 

Idis the id of the record to be unlocked. If given as a null string, all locks in the file identified by FileNo are released.

 

 

The QMRelease function can be used to release a lock without writing or deleting the record. One common use of this function is to release the lock obtained by a call to QMReadl() or QMReadu() where the record was not found and the function returned the SV_ELSE status.

 

 

Examples

 

VB

Rec = QMReadu(fClients, ClientNo, True, ErrNo)

If ErrNo = SV_ELSE Then

  QMRelease(fClients, ClientNo)

  Exit Sub

End If

C

Rec = QMReadu(fClients, ClientNo, TRUE, ErrNo);

if (ErrNo == SV_ELSE)

{

 QMRelease(fClients, ClientNo);

 QMFree(Rec);

 return;

}

QMBasic

Rec = session->Readu(fClients, ClientNo, @true, ErrNo)

if ErrNo = SV_ELSE then

  session->Release(fClients, Id)

  return

end

 

The above program fragment attempts to read a record with an update lock. If the record is not found, the lock is released prior to exit from the subroutine.

 

Note how the C example uses QMFree() to release the dynamic memory allocated to store Rec.