M2M AD301 Uživatelská příručka Strana 164

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 230
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 163
Operator reference
152 Data Integration with Sybase Avaki Studio
Example: Iterating over the elements of an array parameter
The problem
Suppose you want to create a data service that summarizes account information for a list
of customers. The data service must take a parameter containing the array of account
numbers and must produce a result set with a row for each account that includes:
ACCOUNT_NUMBER
LAST_TRANSACTION_DATE
BALANCE
NOTES
For simplicity, assume that there is already a database operation named “GetAc-
countInfo” that returns the LAST_TRANSACTION_DATE, BALANCE, and NOTES val-
ues for a single account, given the account’s number.
The solution
Using Avaki Studio, you create a model with a parameter named “Accounts” of type
INTEGER[] (array of integers). Then, you use the GetAccountInfo database operation
to create an input source (see “Input Source” on page 125), connecting its output to a
new Projection, the output of which goes into an new Iterator and then, finally, to the
Result element.
Configure the Iterator as follows:
Name: Enter “AccountIterator” for the operators name. The name must match the
name used in specifying the variables in the three fields below.
Initialize: Enter the following code:
// Set up the counter we'll use to index the array
variables.AccountIterator.x = 0;
// Get the first array element
variables.AccountIterator.current =
variables.global.Accounts[variables.AccountIterator.x];
Increment: Enter the following code:
// Increment the counter
variables.AccountIterator.x++;
// Get the next array element
variables.AccountIterator.current =
variables.global.Accounts[variables.AccountIterator.x];
Zobrazit stránku 163
1 2 ... 159 160 161 162 163 164 165 166 167 168 169 ... 229 230

Komentáře k této Příručce

Žádné komentáře