CREATE OR REPLACE TYPE geocoord
AS OBJECT
EXTERNAL NAME 'GeoCoordJ'
LANGUAGE JAVA
USING SQLData
( latitude number external name 'latitude',
  longitude number external name 'longitude',
  MEMBER FUNCTION distance (other IN GeoCoord)
    RETURN NUMBER EXTERNAL
    NAME 'distance (GeoCoordJ) return double');
/
CREATE TABLE geoTable OF geocoord;
INSERT INTO geoTable VALUES (geocoord(50,0));
INSERT INTO geoTable VALUES (geocoord(-50,179));

SET SERVEROUTPUT ON
CALL dbms_java.set_output(2000);

SELECT g.distance(geocoord(51.5,0)) FROM geoTable g;
