Input clause

Official Content
This documentation is valid for:

Is used in a Data provider Group statement in order to the associated group could iterate n times, being n the number of elements taken from an input that is not a database table, but a variable that assume multiple values. 

Scaning this variable values, for each one, we will have a group item in the output. That is to say, for each iteration into the variable, we will have an iteration into the group. Thus, we can use the variable iteration information as an input for the group. 

Syntax

Input {<forIter> | <forIn>}

where:

  • <ForIter>::= <&i> '=' <numberFrom> to <numberTo>
            It is like the For command to iterate (i.e. "for &i = ... to ..." but without the "for" keyword)
  • <ForIn>::= <&item> in <SDTcollection>
            
    It is like the For in Command (i.e. "for &item in &SDTCollection..." but without the "for" keyword

 

Description

It is usually necessary to have other kinds of Input data besides database. For example, the output of some Procedure or Data Provider. The obvious way to work with that is through variables that, once assigned, can be treated as usual.

For example, we need a Data Provider that outputs a collection of clients that live in the same neighborhood as the customer returned by another Data Provider. Suppose 'DPSpendsMoreClient' is an already declared Data Provider that returns a customer SDT with the country, city and neighborhood information of the higher spending customer in the Database.

Clients
{
   &Customer = DPSpendsMoreClient()
   Client 
      where CountryId = &Customer.CountryId
      where CityId = &Customer.CityId
      where CustomerNeighborhood = &Customer.Neighborhood
   {
      Name = CustomerName
      Address = CustomerAddress
      Phone = CustomerPhone
   }
}

As you can see, the &customer was taken from another Data Provider and used as usual. But what if we need to work not with a simple data type, but with a collection returned by a Procedure or Data Provider? Or if we need to iterate at certain fixed times? The Input clause lets you work with these other cases.

The simpler one is just a set of fixed values, for example a Data Provider that Outputs the months:

VerySimple
{
   Month Input &i = 1 to 12
   {
      MonthNumber = &i
   }
}

Note: this is similar to a For &i = 1 to 12 in the procedural language.

A more sophisticated Input can be another SDT collection. For example:

CustomersFromAnotherDataProvider
{
   &CustomersSDT = GetCustomers() // a DataProvider that Outputs Customers collection
   Customer Input &Customer in &CustomersSDT
   {
      Id   = &Customer.Code
      Name = &Customer.Name
   }
}

In sum, any collection variable should be treated through the Input clause to achieve iteration.

For a summary of the different Input sources, read Data Provider: Input

 





Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.