Skip to content

When creating a brand-new entity/table in Developer Studio that needs a sequence-generated key (rather than reusing an existing key generator), where do you actually define the Oracle SEQUENCE (and any supporting INDEX), given that hand-editing a `.storage` file isn't something normally done directly in PL/SQL Developer?

Answer

Define the key attribute as a plain NUMBER key in the entity's .entity file; define the actual Oracle SEQUENCE (and any supporting INDEX) in that entity's .storage file, using standard syntax such as SEQUENCE <name> IS MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE ORDER; and INDEX <name> IS <table> (<column>);. Then, in the entity's .plsql file, override the Insert___ method to populate the key attribute from <SEQUENCE_NAME>.NEXTVAL, register it via Client_SYS.Add_To_Attr, and call super(...) afterward. Developer Studio then generates the corresponding SEQUENCE DEFINITIONS and INDEX DEFINITIONS blocks (built from Database_SYS.Create_Sequence / Database_SYS.Create_Index calls) into the entity's .cre file automatically based on those .storage-file definitions — just make sure both generated blocks are included when assembling the final deployment file.

← Browse Developer Studio, deployment, and upgrades questions