WEATHER
The WEATHER function returns information from a TSO data set as a Db2 table. The TSO data set contains sample weather statistics for various cities in the United States. The statistics are returned to the client with a row for each city and a column for each statistic. The WEATHER function is provided primarily to help you design and implement table functions.
The schema is DSN8.
Unlike the other sample user-defined functions, which are scalar functions, WEATHER is a table function. WEATHER shows how to use a table function to make non-relational data available to a client for manipulation by SQL.
- input-data-set-name
- The name of the TSO data set that contains sample weather statistics. The name is a character string with a data type of VARCHAR and an actual length that is not greater than 44 bytes.
The result of the function is a Db2 table with the following columns. Each column
can be null.
- name-of-city
- VARCHAR(30)
- temperature-in-fahrenheit
- INTEGER
- percent-humidity
- INTEGER
- wind-direction
- VARCHAR(5)
- wind-velocity
- INTEGER
- barometer
- FLOAT
- forecast
- VARCHAR(25)
The external program name for the function is DSN8DUWF, and the specific name is DSN8.DSN8DUWF.
Example: Find
the name of and the forecast for the cities that have a temperature
less than 25 degrees.
SELECT CITY, FORECAST
FROM TABLE(DSN8.WEATHER('prefix.SDSNIVPD(DSN8LWC)')) AS W
WHERE TEMP_IN_F < 25
ORDER BY CITY;
This example returns: Bessemer, MI Slight chance of snow
Cheyenne, WY Continued cooling
Helena, MT Heavy snow
Pierre, SD Continued cold