1 TRIGGER PROCEDURE FOR CREATE OF Tenant.
3 DEF VAR tenant-code
LIKE Tenant.TenantCode
NO-UNDO.
4 DEF BUFFER LastTenant
FOR Tenant.
6 FIND LAST LastTenant
NO-LOCK NO-ERROR.
7 IF AVAILABLE(LastTenant
) AND LastTenant.TenantCode
>= 99999 THEN DO:
8 FIND LAST LastTenant
WHERE LastTenant.TenantCode
< 9990 NO-LOCK NO-ERROR.
9 IF AVAILABLE(LastTenant
) AND LastTenant.TenantCode
= 9989 THEN DO:
10 FIND LAST LastTenant
WHERE LastTenant.TenantCode
< 90000 NO-LOCK NO-ERROR.
11 /* sort this one out when we need to
*/
14 tenant-code
= IF AVAILABLE LastTenant
THEN LastTenant.TenantCode
+ 1 ELSE 1.
16 ASSIGN Tenant.TenantCode
= tenant-code.