Page 1 of 1

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

Posted: Wed 28 Nov 2018 11:15
by Akella
Я знаю, что у 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;
и т.д.

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

Posted: Wed 28 Nov 2018 12:23
by ViktorV
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

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

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

Спасибо.

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

Posted: Fri 08 May 2020 09:11
by oleg0k
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

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

Posted: Fri 08 May 2020 09:37
by Akella
move topic to ru-forum. please

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

Posted: Mon 18 May 2020 13:19
by oleg0k
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