There may be occasions when a presentation layer component needs to obtain a new primary key value in its initialisation phase rather than waiting until the submit/store phase. This can be achieved with the following code:
if ($occstatus != "est") & (!$occmod) ; record is new & unmodified ; force session service to supply value for SEQ_NO call VLDF_VIA_SSV("<MAIN>","seq_no") #include STD:FATAL_ERROR endifThis will cause the session service to validate te specified field.
variables string lv_PersonId, lv_OptionId endvariables if ($error = 0129) ; value is required lv_PersonId = person_id.x_option_value lv_OptionId = option_id.x_option_value ; value not supplied yet, so generate it from current highest value selectdb max(seq_no) from "x_option_value" %\ u_where (person_id = lv_PersonId & %\ option_id = lv_OptionId) %\ to seq_no seq_no = seq_no + 1 ; increment to next number return(0) endif call ON_ERROR_F
This happens when you attempt to delete an occurrence which has inner entities defined within the component. If any of these inner entities still have occurrences and the Delete Constraint on the relationship is set to Restricted then this will generate error 0139.
This can also happen if no relationship between the outer and inner entities has been defined in the application model - the delete constraint is assumed to be Restricted.
If the relationship is defined in the application model then you can change the Delete Constraint to either Cascade or Nullify. If there is no relationship then you can use the following code:
if ($occdel($outer)) return(-1) ; don't read if parent being deleted