Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.11 KB

CreateQueryInCycle.md

File metadata and controls

54 lines (39 loc) · 1.11 KB

Execution query on cycle (CreateQueryInCycle)

Description

Execution query in cycle.

Examples

Incorrect

// BanksToProcessing - contains an array of banks

InidividualQuery = New Query("
  |SELECT
  | BankAccounts.Ref AS Account
  |FROM
  | Catalog.BankAccounts AS BankAccounts
  |WHERE
  | BankAccounts.Bank = &Bank");

For Each Bank From BanksToProcess Do
  InidividualQuery .SetParameter("Bank", Bank);
  AccountsSelection = InidividualQuery .Execute().Select();
  While AccountsSelection.Next() Do
    ProcessBankAccounts(AccountsSelection.Account);
  EndDo;
EndDo;

Correct

// BanksToProcess - contains an array of banks

MergedQuery = New Query("
  |SELECT
  | BankAccounts.Ref AS Account
  |FROM
  | Catalog.BankAccounts AS BankAccounts
  |WHERE
  | BankAccounts.Bank In(&BanksToProcess)");

MergedQuery.SetParameter("BanksToProcess", BanksToProcess);
AccountsSelection = MergedQuery.Execute().Select();
While AccountsSelection.Next() Do
  ProcessBankAccounts(AccountsSelection.Account);
EndDo;