9.10. 列舉型別函式
For enum types (described inSection 8.7), there are several functions that allow cleaner programming without hard-coding particular values of an enum type. These are listed inTable 9.32. The examples assume an enum type created as:
Table 9.32. Enum Support Functions
Function | Description | Example | Example Result |
| Returns the first value of the input enum type |
|
|
| Returns the last value of the input enum type |
|
|
| Returns all values of the input enum type in an ordered array |
|
|
| Returns the range between the two given enum values, as an ordered array. The values must be from the same enum type. If the first parameter is null, the result will start with the first value of the enum type. If the second parameter is null, the result will end with the last value of the enum type. |
|
|
|
| ||
|
|
Notice that except for the two-argument form ofenum_range
, these functions disregard the specific value passed to them; they care only about its declared data type. Either null or a specific value of the type can be passed, with the same result. It is more common to apply these functions to a table column or function argument than to a hardwired type name as suggested by the examples.
Last updated