Last active
August 29, 2015 14:10
-
-
Save zazk/01e4caf406b38e91e60a to your computer and use it in GitHub Desktop.
Create AutoIncrement Field Oracle lower 12g
This file contains hidden or 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 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