Previous Topic: Selecting All ColumnsNext Topic: Selecting Using Search Conditions


Selecting Some Columns

A result table can contain only those columns you specifically want to see. To retrieve specific columns, you name those columns in the SELECT statement, as shown in the following:


 Problem

 Select some specific columns from table CUSTOMERS.
 Solution

               .
               .
       (COBOL statements)
               .
               .
  1   EXEC SQL
  2       DECLARE CUSTLIST CURSOR FOR
  3           SELECT CUST_NO, CITY, STATE
  4           FROM CUSTOMERS
  5   END-EXEC.
               .
               .
       (COBOL statements)
               .
               .

Line 3

To retrieve only specific columns for inclusion in your result table, name those columns in the SELECT statement. This example retrieves columns named CUST_NO, CITY and STATE from the CUSTOMERS table to build a result table.