Fujitsu J2X0-1634-01EN Computer Accessories User Manual


 
[Figure: Example of specifying multiple columns in a single row SELECT statement]
If all columns in a table are to be specified in the order in which they were defined, an asterisk can be used to specify
the columns instead of column names. In the following example an asterisk is used to specify columns:
Example 2:
In this example, an asterisk is used to fetch data from all columns in the STOCK table.
SELECT * INTO :ITMNO, :PRODUCT, :STOCKQTY, :WHCODE
FROM STOCKS. STOCK WHERE ITMNO = 215
In Example 2, the specification of the columns from which data is to be fetched is equivalent to the four columns
ITMNO, PRODUCT, STOCKQTY, and WHCODE being specified separately. Therefore, four host variables must be
specified for storing data fetched from columns.
If an asterisk is specified instead of column names, columns may be added or the sequence in which columns are
defined may be modified due to modifications to the design of the table. If this is the case, the application program
must be modified. To prevent modifications needing to be made to the application program, specify the columns to be
accessed and separate them by commas.
2.1.2 Fetching data containing null values
Fetching data containing null values was not considered in the first two examples. This section explains how to fetch
data containing null values.
The variable used to indicate whether a data value is a null value is called the indicator variable. The indicator variable
is paired with a host variable and specified in an SQL statement. When fetching data to be accessed by the
10