1.0

Table Of Contents
AND
(edited_by <> 'fromUpdateTrigger' or edited_by IS NULL);
CREATE TYPE
The CREATE TYPE statement creates a user-dened type (UDT). A UDT is a serializable Java class whose
instances are stored in columns. The class must implement the java.io.Serializable interface.
Syntax
CREATE TYPE [ schema-name. ] SQL92Identifier
EXTERNAL NAME singleQuotedJavaClassName
LANGUAGE JAVA
The type name is composed of an optional schemaName and a SQL92Identier. If a schemaName is not provided,
the current schema is the default schema. If a qualied type name is specied, the schema name cannot begin
with SYS.
If the Java class does not implement java.io.Serializable, or if it is not public and visible on the classpath, SQLFire
raises an exception when preparing statements which refer to the UDT.
A UDT cannot be cast explicitly to any other type, and no other type can be cast to a UDT.
A UDT has no ordering. This means that you cannot compare and sort UDTs. You cannot use them in expressions
involving the <, =, >, IN, BETWEEN, and LIKE operators. You cannot use UDTs in aggregates, DISTINCT
expressions, and GROUP/ORDER BY clauses. You cannot build indexes on them.
You can use subtypes in UDTs. That is, if you use the CREATE TYPE statement to bind a class named C to a
UDT, you can populate that UDT value with an instance of any subclass of C.
Example
CREATE TYPE price
EXTERNAL NAME 'com.acme.types.Price'
LANGUAGE JAVA
Using user-defined types
You can create tables and views with columns that have UDTs. For example:
CREATE TABLE order
(
orderID INT GENERATED ALWAYS AS IDENTITY,
customerID INT REFERENCES customer( customerID ),
totalPrice typeSchema.price
);
Although UDTs have no natural order, you can use generated columns to provide useful sort orders:
ALTER TABLE order
ADD COLUMN normalizedValue DECIMAL( 31, 5 ) GENERATED ALWAYS AS
467
SQL Language Reference