Using Cloudscape's Java Extensions
Page 6 of 12

Orderable Java Data Types

Cloudscape allows you to create special Java data types that allow for ordering capabilities usually only allowed on built-in data types. For example, if a Java data type is orderable, you can:

  • use it in MAX/MIN aggregate operations
  • use it to order results such as in a DISTINCT, GROUP BY, UNION, or ORDER BY operation
  • Use the comparisons <, >, <=, >=
  • Create indexes or primary, foreign key, or unique constraints on a column that contains the type.

The JBMSTours application contains one orderable Java data type, JBMSTours.serializabletypes.City. Here are some examples of what you can do with this special class:

-- use in primary key constraints
CREATE TABLE Cities (city SERIALIZE(City) PRIMARY KEY)

-- comparisons
SELECT city
FROM Cities
WHERE city < (SELECT city FROM cities WHERE city_id = 35)

-- ordering
SELECT city FROM Cities
ORDER BY city

-- MAX
SELECT MAX(city) FROM Cities

For information on how to create these classes, see Programming Orderable Classes.