3tier_banner.gif Main Index  PREV  NEXT

Valid HTML 4.01!   Valid CSS!


How to initialise a technical key using a session service

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:

  1. In the <occ. gets focus> trigger in the presentation layer component:
    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
    This will cause the session service to validate te specified field.
  2. In the <on error> trigger for the field in the session service
       string  lv_PersonId, lv_OptionId
    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
    call ON_ERROR_F

Error 0139: Entity has restricted links to ?

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:

  1. In the <read> trigger of the inner entity:
    if ($occdel($outer)) return(-1) ; don't read if parent being deleted

copyright.gif http://www.tonymarston.net