CREATE OR REPLACE TYPE jgeocoord          -- Typname, der in SQL verwendet wird
AS OBJECT
EXTERNAL NAME 'GeoCoordJ  '         -- Name der Java-Klasse, die verwendet wird
LANGUAGE JAVA
USING SQLData
( latitude NUMBER EXTERNAL NAME 'lat',  -- Mapping der Attributnamen SQL<->Java
  longitude NUMBER EXTERNAL NAME 'lon',
  MEMBER FUNCTION distance (other IN jgeocoord) RETURN NUMBER   -- Signatur SQL
    EXTERNAL NAME 'distance (GeoCoordJ) return double');    -- Signatur in Java
/
CREATE TABLE jcoordtable OF jgeocoord;
INSERT INTO jcoordtable VALUES (jgeocoord(50,0));
INSERT INTO jcoordtable VALUES (jgeocoord(-34,151));

SELECT x.longitude, x.distance(jgeocoord(51.5,0))
FROM jcoordtable x;
