Автогенерация InsertSQL, UpdateSQL

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Akella
Posts: 8
Joined: Mon 02 Apr 2012 12:04

Автогенерация InsertSQL, UpdateSQL

Post by Akella » Wed 28 Nov 2018 11:15

Я знаю, что у TUniQuery есть возможность сгенерировать доп. запрос на основе SelectSQL.
Но делает это неочевидно. Нет готовых методов.
Приходится открывать предварительно сам запрос, что есть не совсем правильно.

Code: Select all

        UniQuery1.Open;
        UniQuery1.SQLUpdate.Text := TDBAccessUtils.SQLGenerator(UniQuery1).GenerateSQL(TDAParamsInfo.Create(TDAParamInfo) , _stUpdate, true);
        UniQuery1.SQLRefresh.Text := TDBAccessUtils.SQLGenerator(UniQuery1).GenerateSQL(TDAParamsInfo.Create(TDAParamInfo) , _stRefresh, true);
без UniQuery1.Open вываливается AV.

Было бы здорово, если бы было что-то вроде:
UniQuery1.GelerateAllSQLs.
UniQuery1.GelerateInsertSQL;
UniQuery1.GelerateUpdateSQL;
UniQuery1.GelerateDeleteSQL;
и т.д.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Автогенерация InsertSQL, UpdateSQL

Post by ViktorV » Wed 28 Nov 2018 12:23

We see no reason for adding this functionality. But you can place this suggestion at our user voice forum: https://devart.uservoice.com/forums/104 ... components If the suggestion gets a lot of votes, we will consider the possibility to implement it.
To solve your task, you can declare a TUniQuery descendant and add the required methods.
Note, internal methods are involved in the code and improper use can lead to unpredictable consequences.
Please ask questions in Russian on the forum: ru

Akella
Posts: 8
Joined: Mon 02 Apr 2012 12:04

Re: Автогенерация InsertSQL, UpdateSQL

Post by Akella » Tue 05 May 2020 14:33

Добрый. Прошло уже почти 1,5 года. Вопрос все ещё актуален.
Не появились ли "простые" методы для автогенерации запросов без открытия набора данных, чтобы не приходилось выполнять UniQuery1.Open?

Спасибо.

oleg0k
Devart Team
Posts: 190
Joined: Wed 11 Mar 2020 08:28

Re: Автогенерация InsertSQL, UpdateSQL

Post by oleg0k » Fri 08 May 2020 09:11

Hello,
To generate InsertSQL and UpdateSQL, a list of fields must be retrieved; if a query is in the form of SELECT * FROM TABLE_NAME, the Open method must be executed in any event to get a list of fields.
The query may contain a view or a stored procedure that may return a dataset in some database systems, therefore the results of the query must be processed to check whether the dataset is modifiable or not.
If a stored procedure can modify data, implicit execution of it is strictly forbidden.
Thus, an additional query for metadata is required to identify where the SELECT query is coming from, a table, a view or a stored procedure.
Please ask questions in Russian on the forum: ru

wbr, Oleg
Devart Team

Akella
Posts: 8
Joined: Mon 02 Apr 2012 12:04

Re: Автогенерация InsertSQL, UpdateSQL

Post by Akella » Fri 08 May 2020 09:37

move topic to ru-forum. please

oleg0k
Devart Team
Posts: 190
Joined: Wed 11 Mar 2020 08:28

Re: Автогенерация InsertSQL, UpdateSQL

Post by oleg0k » Mon 18 May 2020 13:19

Hello,
Unfortunately, forum architecture limitations don't allow moving the current thread to the RU forum.
You may ask your further questions in the Russian version of the forum

wbr, Oleg
Devart Team

Post Reply