Last active
August 29, 2015 14:09
-
-
Save cwhite92/0a71a348ebac0041cc17 to your computer and use it in GitHub Desktop.
Google maps API lat/long trigger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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