* * *

Author Topic: [SOLVED] IBX for Lazarus ReadOnly property is not published ?  (Read 1257 times)

patyi

  • Full Member
  • ***
  • Posts: 151
[SOLVED] IBX for Lazarus ReadOnly property is not published ?
« on: January 01, 2018, 11:14:00 pm »
Hi all !
I'm testing IBX for Lazarus, actually making a small project for stock managing and need some operation with IBDataSet in read only mode, but I can't find ReadOnly property ! It is not published ? In documentation mentioned that all descendent's of TDataset have ReadOnly property ! I can't find it ! How to get the ReadOnly mod ?

I'd like to thanks to MWA Software for that wonderful component set !  :D
« Last Edit: January 02, 2018, 03:22:18 pm by patyi »

rvk

  • Hero Member
  • *****
  • Posts: 3448
Re: IBX for Lazarus ReadOnly property is not published ?
« Reply #1 on: January 01, 2018, 11:33:49 pm »
As far as I know any TIBDataset has never had a readonly property. If you want it to be readonly, just don't define any InsertSQL, DeleteSQL and UpdateSQL for it.

To what documentation are you referring? (It might need an update)
(Does it say "any descendant must have" ?)

B.T.W. you can set TFields to readonly.

Also... I would use TIBQuery.
(It has more capabilities like join and should automatically be readonly, unless a TIBUpdateSQL is added/connected)
« Last Edit: January 01, 2018, 11:41:26 pm by rvk »

rvk

  • Hero Member
  • *****
  • Posts: 3448
Re: IBX for Lazarus ReadOnly property is not published ?
« Reply #2 on: January 01, 2018, 11:52:29 pm »
O, and from the documentation:
(see pdf's at http://www.mwasoftware.co.uk/documentation)

Quote
You will normally want to use TIBDataset instead of a TIBQuery and TIBUpdateSQL pair. The main use of the latter combination is, for example, when a form uses a TIBQuery to provide a read only dataset, and a subclassed (inherited) form needs to update the dataset. The IBUpdateSQL can be added to the subclassed form to provide the update capability.

As I said, I actually always used TIBQuery with TUpdateSQL in Delphi and never TIBDataset. But as you can see the TIBQuery is inherently read-only (until TIBUpdateSQL is added).


rvk

  • Hero Member
  • *****
  • Posts: 3448
Re: IBX for Lazarus ReadOnly property is not published ?
« Reply #3 on: January 02, 2018, 12:02:04 am »
Hahaha, and I see you are correct:

From the documentation of IBX itself:
Quote
All the IBX TDataset subclasses support the following properties
ReadOnly Set to true to disable changes to an otherwise writeable
dataset.

Point 6.2.1 page 39.

tonyw

  • Full Member
  • ***
  • Posts: 118
    • MWA Software
Re: IBX for Lazarus ReadOnly property is not published ?
« Reply #4 on: January 02, 2018, 10:52:13 am »
Hahaha, and I see you are correct:

From the documentation of IBX itself:
Quote
All the IBX TDataset subclasses support the following properties
ReadOnly Set to true to disable changes to an otherwise writeable
dataset.

Point 6.2.1 page 39.

Oh well we all make mistakes  :-[ The only IBX TDataset to have a readonly property is TIBTable. None of the others do or need to have one. I have updated the working copy of the documentation to reflect that.

If you want a true read only dataset then use TIBQuery. If you want a temporary read only dataset then use TIBQuery with TIBUpdateSQL. If you set the TIBQuery.UpdateObject to nil then it's readonly, Set TIBQuery.UpdateObject to point to the TIBUpdateSQL then it becomes read/write. You should be able to do this at run time to dynamically change the dataset from read only to read/write and vice versa - but make sure that the dataset is in the dsBrowse state when you do this.

If you want a permanent read/write dataset then use TIBDataset or TIBQuery with TIBUpdateSQL.

Tony Whyman
MWA Software

tonyw

  • Full Member
  • ***
  • Posts: 118
    • MWA Software
Re: IBX for Lazarus ReadOnly property is not published ?
« Reply #5 on: January 02, 2018, 11:19:00 am »
It's also worth remembering that Firebird Transactions add another dimension to making a dataset read only. If the transaction is read only then it doesn't matter whether you are using TIBQuery or TIBDataset, you will always get an exception when you try and post an update or delete a row.

If you really want to prevent a given user from updating the database (or just some tables) then use Firebird's built-in security. If a given user (or role) is not granted UPDATE, INSERT or DELETE privilege on a given table then it does not matter whether the transaction is read/write or if the dataset is read/write, that user will not be able to modify the underlying table.

Tony Whyman
MWA Software

patyi

  • Full Member
  • ***
  • Posts: 151
Re: IBX for Lazarus ReadOnly property is not published ?
« Reply #6 on: January 02, 2018, 03:21:43 pm »
Thanks rvk, tonyw !
Now it's clear !  Despite this small mistake, the documentation is excellent ! :D
First of all, because it exists, well organized and readable !

I come from the ZeosDBO world where there is ReadOnly property, although I wanted to work with IBX, but I'll solve it differently - as tonyw suggested by setting nil the UpdateObject property !

Thank you for your help !

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus