Build an auto increment entity
Hint: Check the New Base Entity with Retrieval of the generated key paragraph below because there is now a pattern for this stuff!
A short how-to build an auto increment entity:
1. Your entity must be known by a numeric identifier (inherit from 'aa Identifier')
2. Create a separate insert view:
3. Put an insert row function in that view and modify the "SUB insert row" because you can't use / won't need the check row function.
4. Gen&Build your DB and modify the key column type native in your DB. Plex doesn't know a auto increment type.
HINT 1: One drawback of the auto increment is that you won't be able to pass the new identifier back to your calling function. So if you need the new record key for further reference you should use 'SEC_V20/NbrKey.BusinessExtraFunctions.GetNextNumber'.
HINT 2: See DB specific Selects for generated key values below if you need to access the new identifier.
New Base Entity with Retrieval of the generated key
- inherit from PATTY/all RelationalTableAutoKey
- replace PATTY/all KeyFieldNbr(15) by your ID
- set the property de.allabout.db.idselect in your obsvr.properties to a DB specific value ( see below)
- in BusinessBaseFunctions.Insert
- replace the Update.InsertRow Function with the new Insert.InsertRow Function
- map the new Key Variable from the FullRecord-Variable
- be sure the the GetNextNumber Function is not called ( undefine "PreSetValues" AND set the Key to -1 to get through Validation)
- Gen&Build your DB and modify the key column type native in your DB. Plex doesn't know a auto increment type.
DB specific Selects for generated key values
in the obsvr.properties we have a new property "de.allabout.db.idselect=@dbidselect@", where @dbidselect@ should be either replaced by your specific select or provided by a deployment property specified in your localtomcat.properties oder servertomcat.properties
- MS SQL dbidselect=select @@IDENTITY
- MySQL dbidselect=select LAST_INSERT_ID()
- DB2/400 (naming=system) dbidselect=SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM/SYSDUMMY1
- DB2/400 (naming=sql) dbidselect=SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1
- DB2/400 (SYSIBM in library-list) dbidselect=SELECT IDENTITY_VAL_LOCAL() FROM SYSDUMMY1

