FEATURES batch request to the "1C: Enterprise 8.2
"
Emelyanova Ekaterina, 4th year student of
the specialty " 5B070300 - Information Systems" Sh . A.Baitursynov
Irina Morozova , Senior Lecturer , Department of Information Systems
KSU . A.Baitursynov
Batch Queries logical complement the functionality of temporary tables and
allow more flexibility in dealing with requests.
In fact, query batch several requests can be described as interconnected
using temporary tables , and not related . As a result, you can perform
consistently and accept all requests as a result of either an array with the
results of each query execution , or the result of the latter. For an array
with the results of the query method is used " VypolnitPaket()"
object request and to obtain the result of the last request
"VypolnitZapros()".
The text of the query, the query packet are separated by " , " (
comma) . The namespace of virtual tables in one batch request one . Using time
management table is not required, but it is possible if required to convey the
temporary table from one batch to another request .
We rewrite the procedure for batch queries :
Процедура ОбработкаПроведения(Отказ, РежимПроведения)
Запрос = Новый Запрос;
Запрос.Текст = "
|ВЫБРАТЬ
| Номенклатура, СУММА(Количество) КАК Количество
|ПОМЕСТИТЬ ДокТЧ
|ИЗ Документ.Расходная.Товары
|ГДЕ Ссылка = &Ссылка
|СГРУППИРОВАТЬ ПО Номенклатура
|
|;
|
|ВЫБРАТЬ РАЗЛИЧНЫЕ
| Номенклатура
|ПОМЕСТИТЬ СписокТоваров
|ИЗ Документ.Расходная.Товары
|ГДЕ Ссылка = &Ссылка
|
|;
|
|ВЫБРАТЬ
| Док.Номенклатура,
| Док.Количество КАК Док_Количество,
| ЕСТЬNULL(Рег.КоличествоОстаток,0) КАК Рег_Количество
|ИЗ
| ДокТЧ КАК Док
| ЛЕВОЕ СОЕДИНЕНИЕ
| РегистрНакопления.ОстаткиТоваров.Остатки(,
| Номенклатура В(ВЫБРАТЬ РАЗЛИЧНЫЕ
| Номенклатура
| ИЗ
| СписокТоваров КАК СписокТоваров)) КАК Рег
| ПО
| Док.Номенклатура = Рег.Номенклатура";
Запрос.УстановитьПараметр("Ссылка", Ссылка);
МассивРезультаттов = Запрос.ВыполнитьПакет(); //Прим.
1
РезультатЗапроса= Запрос.Выполнить(); //Прим. 2
Выборка = РезультатЗапроса.Выбрать();
Пока Выборка.Следующий() Цикл
//Проверка отрицательных остатков
//Проведение по регистру
КонецЦикла;
КонецПроцедуры
In fact, we remove the
definition of the object query manager, and the use of temporary tables that
combine text queries (note the delimiter " ; " between the texts ) .
As a result of the query text was easier to read (and if you use the query
design greatly increase the readability of the query).
After the query into a
variable "MassivRezultatov" we will get 3 items . The first two will
contain a number characterizing the number of records placed into temporary tables
and DokTCh SpisokTovarov, and the third will contain a selection of the fields
"Nomenclature","Dok_Kolichestvo" and "Reg_Kolichestvo."
In the variable " RezultatZaprosa " gets only a sample.
The algorithm batch
request can be considered a convenient mechanism for writing and reading
complex queries.