Updtick
This technical column is added in every database table when the table is validated in version 7 for the supervisor. This column stores a revision number for every line in the database. The revision numbers start at 1 when a line is created, and increment by 1 every time an update is made through a database trigger.
Updtick is also a system property that exists in every class or representation instance (it does not have to be declared in the class or representation dictionary). When a standard 'read' method is used on a persistent class, the SetInstance
transfers the Updtick
value from the database table to the class to manage concurrent updates.
For detailed information, see the corresponding reference document.
[xxxx]UpdtickMYINSTANCE.Updtick
Subprog UPDATE_CUST(CUST_CODE,ERR_MSG)Value Char CUST_CODE()Variable Char ERR_MSG# Table declarationLocal File CUSTOMER [CUST]Local File CUSTOMER [CUS1]Local Instance MY_CUSTOMER Using C_CUSTOMERRead [CUST]KEY=CUST_CODEIf fstatERR_MSG="Customer does not exist" : EndEndifSetInstance MY_CUSTOMER With [CUST]Gosub LONG_PROCESS_UPDATING_MY_CUSTOMER_STEP_1Read [CUS1]KEY=CUST_CODEIf MY_CUSTOMER.Updtick<>[CUS1]UpdtickERR_MSG="The customer was modified after step 1" : EndEndifGosub LONG_PROCESS_UPDATING_MY_CUSTOMER_STEP_2SetInstance [CUST] With MY_CUSTOMER# The RewriteByKey instruction performs the update only if Updtick has not changedRewriteByKey [CUST]KEY=CUST_CODEIf fstat>=6ERR_MSG="The customer was modified or deleted after step 2" : EndElsif fstat<>=0ERR_MSG="AN error occured at update time fstat="+num$(fstat) : EndEndif# At this step, as the update has been successful, [CUST]UPdtick is equal to MY_CUSTOMER.Updtick+1ERR_MSG="The customer record has been successfully updated to revision "+num$([CUST]Updtick)End
DeleteByKey, RevertUpdtick, RewriteByKey, Updtick definition