Exclusive access to a Chart in Firebird Got How?

Asked

Viewed 398 times

2

Would Open a Table in Mode Exclusive in the Firebird for Delphi preventing other users from opening the Table?

I use Delphi 10.1 and Firedac for connection to the database.

2 answers

5

You will need to have good transactional control to succeed with this type of treatment.

Use the with lock and a block will be made on the table data, preventing changes or deletions of the selected data!

Ex:

Blocking a record: SELECT * FROM CLIENTES WHERE CODIGO = 255 WITH LOCK this way the Client of code 255 will be blocked for changes/exclusions.

For the entire table do not use filters.

Source: Firebird.Org

  • beauty understands... More like I would one TFDtable? type tbUsuarios.open only in Exclusive mode boqueado the whole table...

  • 2

    This open will execute a certain SQL query? If so.... add the with lock

  • No. This is a Component TFDTable firedac

  • 2

    the TFDTable has the option Exclusive which is a boolean, and has an equivalent option in the property UpdateOption.

  • 1

    I’ve never done this I’m new to Delphi ... would have how to test if the registration is even blocked?

1


I managed to do so:

// Eu desativei o "AutoCommit" pois sem desativar não Funciona.
DM.TFDConnection.TxOptions.AutoCommit := False;
DM.TFDQuery.Close;
DM.TFDQuery.SQL.Clear;
// Trava a Linha da tabela com essa SQL
vSql := 'SELECT * FROM TABELA '+
        'WHERE FIELD1 = FIELD1 WITH LOCK';
DM.TFDQuery.SQL.Add(vSql);
DM.TFDQuery.Open;
{ Aqui você faz o que tem que fazer antes de Desbloquear}
  Depois destarva Com "COMMIT" ou "ROLLBACK"
DM.TFDConnection.TxOptions.AutoCommit := True;

I hope I’ve helped.

  • 1

    I haven’t tested whether DM.TFDConnection.TxOptions.AutoCommit := True; unlock the table.

  • 1

    I’ll try here to see how it goes.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.