Result sets and iterators
When you declare an iterator class, you specify a set of Java™ variables to match the SQL columns that your SELECT statement returns. There are two types of iterators: positional and named.
Positional iterators
The order of declaration of the Java™ variables of a positional iterator must match the order in which the SQL columns are returned. You use a FETCH...INTO statement to retrieve data from a positional iterator.
#sql iterator CustIter( int , String, String, String, String, String );
SELECT customer_num, fname, lname, address1,
address2, phone
FROM customer
Named iterators
The name of each Java™ variable of a named iterator must match the name of a column returned by your SELECT statement; order is irrelevant. The matching of SQL column name and iterator column name is case insensitive.
You use accessor methods of the same name as each iterator column to obtain the returned data, as shown in the example in A simple embedded SQLJ program. The SQLJ translator uses the iterator column names to create accessor methods. Iterator column names are case sensitive; therefore, you must use the correct case when you specify an accessor method.
You cannot use the FETCH...INTO statement with named iterators.
#sql iterator CustRec(
int customer_num,
String fname,
String lname ,
String company ,
String address1 ,
String address2 ,
String city ,
String state ,
String zipcode ,
String phone
);
SELECT * FROM customer