Single-Element Functions : Calling Single-Element Functions : Examples of Single-Element Function Calls : Single-Element Function Example 2

Single-Element Function Example 2

The following example shows functions that return enumerated type values.

VARIABLE
STATE state_id;
STRING state_name, state_type;
INTEGER st_type;
INTEGER status;
.
.
state_id := stm_r_st (state_name, status);
st_type := stm_r_st_type (state_id, status);
SELECT
WHEN st_type = stm_st_or =>
state_type := ’or’;
WHEN st_type = stm_st_and =>
state_type := ’and’;
.
.
END SELECT;
WRITE (’The state ’,state_name, ’is of type ’,
state_type);

This example queries the database to determine the type of the state in state_name. When the type is determined, the name and type of the state are printed out.