Skip to content

Instantly share code, notes, and snippets.

@zazk
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save zazk/01e4caf406b38e91e60a to your computer and use it in GitHub Desktop.

Select an option

Save zazk/01e4caf406b38e91e60a to your computer and use it in GitHub Desktop.
Create AutoIncrement Field Oracle lower 12g
-- Create Sequence
CREATE SEQUENCE USU_seq;
-- Create Trigger to manage fake autoincrement
CREATE OR REPLACE TRIGGER usu_bir
BEFORE INSERT ON geo_usuarios
FOR EACH ROW
BEGIN
-- select next index from our sequence
SELECT usu_seq.NEXTVAL
-- chose autoincremental field (Warning: Verify your field name)
INTO :new.idusuario
FROM dual;
END;
--Select your current sequence index (At least used 1 time)
--SELECT usu_seq.CURRVAL from dual;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment