5. Working with a Database : How You Can Access a Database with Standard SQL Statements : Select Statement : Example—Select Loop
 
Share this page                  
Example—Select Loop
Suppose that cust is a class with attributes that correspond to columns in the customer table. The following select loop extracts information from the customer table and stores it in an array of cust objects:
declare
    cust_arr        = array of cust;
    i               = integer not null;
enddeclare
{
...

i = 1;
select         acctnum    as cust_arr[I].accnt,
               cname      as cust_arr[I].name,
               cphone     as cust_arr[I].phone

    from       customer
    order by   cname
    {
               i = i + 1;
    };
    ...
}