CREATE OR REPLACE TYPE geocoord
AS OBJECT EXTERNAL NAME 'GeoCoordJ'
LANGUAGE JAVA USING SQLData(
longitude number external name 'longitude',
latitude number external name 'latitude',
MEMBER FUNCTION distance (other IN GeoCoord)
  RETURN NUMBER EXTERNAL NAME
   'distance (GeoCoordJ) return double');
/

CREATE TABLE geoTable OF geocoord;
INSERT INTO geoTable VALUES (geocoord(10,20));
INSERT INTO geoTable VALUES (geocoord(20,30));

SET SERVEROUTPUT ON
CALL dbms_java.set_output(2000);

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