Table - verificar se esta locked |
Top Previous Next |
|
De: Alessandro FEIJÓ <power@suply.com> Assunto: Re: Como verificar se um registro está LOCKED? Data: Terça-feira, 18 de Maio de 1999 09:12
if IsRecordLocked(Tabela1, True) then ShowMessage('O Registro está em uso por outro usuário');
//código da função
function IsRecordLocked(Table: TTable; ByAnyone: boolean): boolean; var Locked: BOOL; hCur: hDBICur; rslt: DBIResult;
begin Table.UpdateCursorPos; // Is the record locked by the current session... Check(DbiIsRecordLocked(Table.Handle, Locked)); Result := Locked; // If the current session does not have a lock and the ByAnyone varable is // set to check all sessions, continue check... if (Result = False) and (ByAnyone = True) then begin // Get a new cursor to the same record... Check(DbiCloneCursor(Table.Handle, False, False, hCur)); try // Try and get the record with a write lock... rslt := DbiGetRecord(hCur, dbiWRITELOCK, nil, nil); if rslt <> DBIERR_NONE then begin // if an error occured and it is a lock error, return true... if HiByte(rslt) = ERRCAT_LOCKCONFLICT then Result := True else // If some other error happened, throw an exception... Check(rslt); end else // Release the lock in this session if the function was successful... Check(DbiRelRecordLock(hCur, False)); finally // Close the cloned cursor... Check(DbiCloseCursor(hCur)); end; end; end;
--
baita abraço Feijó feijo@suply.com http://www.suply.com/delphi
Fireman Help Desk Software http://www.sial.com.br
Guionardo Furlan escreveu na mensagem <7hpodp$icb50@oiapoque2.uol.com.br>... >Buenas > >Como posso saber se um registro pode ser alterado (para desabilitar os >componentes relativos aos dados deste)? > >Obrigado >
|