FIREBIRD - how to make a table in FireDAC read only?

FIREBIRD - how to make a table in FireDAC read only?

I could set all the database controls in the GUI to read only but that’s some effort. (yes I’m lazy, using data aware GUI controls, its just so easy to pretend we’re still in the 1990s…!) Is there a way to set each table as Read Only?

Using FireDAC, Delphi 10.3.3 Enterprise, Firebird 3.07 running as a service on Windows 10.

FDQUERY …
UpdateOptions.ReadOnly Specifies whether it is a read-only dataset. The default value is False. If the value of this property is set to True, the EnableDelete, EnableInsert and EnableUpdate properties will be automatically set to False.

1 Like

Hi Martin

Perhaps you could write a helper class for the TFDQuery, TFDTable etc to fail (or silently abort) in the BeforePost and BeforeDelete events.
I’m not sure what can be done about stored procedures that update the database.

You may even be able to write a helper for the TFDConnection component…

Regards
Graeme

Assuming you want your TFDQuery to be read-only sometimes and other time writable I would do this via the TDataSource.AutoEdit property rather than through FireDAC.

When you turn off TDataSource.AutoEdit your data aware controls connected to that datasource won’t allow any changes until you explicitly call TFDQuery.Edit or TFDQuery.Insert.

Agghh!

Thanks Paul - why couldn’t I find that.(TQuery | UpdateOptions | ReadOnly )

Should have gone to Spec Savers!

Easy fix, we’re in business.

Thanks for all the other replies too. See you all down at Spec Savers…:rofl:le:

Cheers

Martin

2 Likes