Skip to content

Instantly share code, notes, and snippets.

@cwhite92
Last active August 29, 2015 14:09
Show Gist options
  • Save cwhite92/0a71a348ebac0041cc17 to your computer and use it in GitHub Desktop.
Save cwhite92/0a71a348ebac0041cc17 to your computer and use it in GitHub Desktop.
Google maps API lat/long trigger
CREATE OR REPLACE TRIGGER trg_products_location
BEFORE INSERT OR UPDATE OF postcode ON products FOR EACH ROW
DECLARE
l_lat VARCHAR2(100);
l_lng VARCHAR2(100);
BEGIN
brian.POSTCODE_TO_LAT_LNG_GM_API(:NEW.POSTCODE, l_lat, l_lng);
:NEW.LOCATION := SDO_GEOMETRY(2001, -- SDO_GTYPE
8307, -- SDO_SRID
SDO_POINT_TYPE(
l_lng, -- X longitude
l_lat, -- Y latitude
null -- Z, not needed for 2D location
),
null, -- SDO_ELEM_INFO_ARRAY
null
); -- SDO_ORDINATE_ARRAY
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment