MyDAC

TMyQuery Class

A component for executing queries and operating record sets. It also provides flexible way to update data.

For a list of all members of this type, see TMyQuery members.

Unit

MyAccess

Syntax

TMyQuery = class(TCustomMyDataSet);

Remarks

TMyQuery is a direct descendant of the TCustomMyDataSet component. It publishes most of its inherited properties and events so that they can be manipulated at design-time.

Use TMyQuery to perform fetching, insertion, deletion and update of record by dynamically generated SQL statements. TMyQuery provides automatic blocking of records, their checking before edit and refreshing after post. Set SQL, SQLInsert, SQLDelete, SQLRefresh, and SQLUpdate properties to define SQL statements for subsequent accesses to the database server. There is no restriction to their syntax, so any SQL statement is allowed. Usually you need to use INSERT, DELETE, and UPDATE statements but you also may use stored procedures in more diverse cases.

To modify records, you can specify KeyFields. If they are not specified, TMyQuery will retrieve primary keys for UpdatingTable from metadata. TMyQuery can automatically update only one table. Updating table is defined by the UpdatingTable property if this property is set. Otherwise, the table a field of which is the first field in the field list in the SELECT clause is used as an updating table.

The SQLInsert, SQLDelete, SQLUpdate, SQLRefresh properties support automatic binding of parameters which have identical names to fields captions. To retrieve the value of a field as it was before the operation use the field name with the 'OLD_' prefix. This is especially useful when doing field comparisons in the WHERE clause of the statement. Use the TCustomDADataSet.BeforeUpdateExecute event to assign the value to additional parameters and the TCustomDADataSet.AfterUpdateExecute event to read them.

Inheritance Hierarchy

TMemDataSet
   TCustomDADataSet
      TCustomMyDataSet
         TMyQuery

See Also

© 1997-2017 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback