Skip to content

Instantly share code, notes, and snippets.

@bradbrowne
Last active November 8, 2016 02:50
Show Gist options
  • Save bradbrowne/386a121614687d810e1c08e4397e84c4 to your computer and use it in GitHub Desktop.
Save bradbrowne/386a121614687d810e1c08e4397e84c4 to your computer and use it in GitHub Desktop.
create or replace TRIGGER ASSET.ASSET_ID_BASE_POINT_TR
-- Automatically assigns new ASSET_ID based on a Sequence
BEFORE INSERT
OR UPDATE -- Required for ArcGIS REST API compatibility
ON ASSET.ASSET_BASE_POINT
FOR EACH ROW
DECLARE
BEGIN
IF :NEW.asset_id IS NULL THEN
IF :OLD.asset_id IS NULL THEN
-- Assign new value from Sequence
:NEW.asset_id := ASSET.ASSET_ID_SQ.NEXTVAL;
ELSE
-- Do not get another value from Sequence
:NEW.asset_id := :OLD.asset_id;
END IF;
END IF;
EXCEPTION WHEN OTHERS THEN RAISE; END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment