Page 1 of 1

TOraQuery.CanModify

Posted: Thu 17 Nov 2011 14:00
by menta
Hi all,
whatever sql I set to a TOraQuery, propery CanModify is True.

for example if I run the following piece of code:

Query.SQL.Text := 'SELECT ''1'' as pippo from dual';
Query.Open;
Assert(not Query.CanModify);

assertion fails.

In BDE, if I requested this query to be "live", it would rise an exception "table is readonly".

How can I understand that a query is not editable in odac?

Thank you!

lorenzo

Posted: Mon 21 Nov 2011 08:48
by AlexP
Hello,

To forbid data editing, you need to set the ReadOnly property to true. In this case the CanModify property will be set to false automatically.

Posted: Tue 22 Nov 2011 10:25
by menta
Hi AlexP,
thank you for your reply!

My problem is that I don't know if the query is editable: it is a custom query, inserted by the user, and system should allow the user to edit it only if it is editable.

Posted: Wed 23 Nov 2011 12:26
by AlexP
Hello,

To check the capability of editing DataSet, you need to set the SetFieldsReadOnly option to true – in this case the CanModify property will be set correctly. But this option usage will decrease performance:

Code: Select all

  OraQuery1.SQL.Text := 'SELECT ''1'' as pippo from dual';
  OraQuery1.Options.SetFieldsReadOnly := true;
  OraQuery1.Open;
  Assert(not OraQuery1.CanModify);