Page 1 of 1
Modify auto-generated SQL statements
Posted: Thu 25 May 2017 07:49
by MICHALA
How(and where) can I see and modify, in the runtime auto generated INSERT / UPDATE / DELETE statments?
Ignore, change, expand, add support for other tables?
Michal
Re: Modify auto-generated SQL statements
Posted: Mon 29 May 2017 13:45
by azyk
If the TUniQuery.SQLInsert.Text / TUniQuery.SQLUpdate.Text / TUniQuery.SQLDelete.Text property is empty, UniDAC automatically generates and executes INSERT/UPDATE/DELETE query only for the main table.
You can see the SQL query (but not modify) which UniDAC will execute when changing data using the BeforeUpdateExecute event handler. For example:
Code: Select all
procedure TForm1.UniQuery1BeforeUpdateExecute(Sender: TDataSet;
StatementTypes: TStatementTypes; Params: TDAParams);
var
SQLText: string;
UpdateQuery: TComponent;
begin
if stInsert in StatementTypes then begin
UpdateQuery := TDBAccessUtils.GetUpdateQuery(TCustomDADataset(Sender));
SQLText := TDBAccessUtils.GetSQL(UpdateQuery).Text;
...
end;
You can create custom SQL queries to change data and then in run-time or design-time set them to the TUniQuery.SQLInsert.Text / TUniQuery.SQLUpdate.Text / TUniQuery.SQLDelete.Text property.
More details about dataset properties SQLInsert/SQLUpdate/SQLDelete in our online documentation:
https://www.devart.com/unidac/docs/?dev ... embers.htm