perhaps you are interested ...

Author: ulrichmerkel@web.de (ulrich-merkel)

once, we had a field called "STUFE" as part of the PK and anything was fine.

Then one decided that STUFE needs to be modifyable and used a TK instead.

Unfortunately, they still want to assure there will be no duplicate value of STUFE.

And they have components where they can add multiple new occs.

Our LFLD trigger (asssumes there will never be an empty value allowed) reads now:

variables
   numeric v_savepos
   string v_valuelist
endvariables
v_savepos = $curocc("<$entname>")
setocc "<$entname>",1  ; to get a complete list, we have to start at occ 1
putlistitems v_valuelist, "<$fieldname>"
setocc "<$entname>",v_savepos  ; reeposition to saved pos
delitem v_valuelist,v_savepos  ; delete "own" value from the list
if ($item(<$fieldname>,v_valuelist) != "") ; and compare
   message/error "duplicate Stufe encountered"
   return (-2)
endif
 

Perhaps one has other ideas how to implement that task?

(Just to keep you fit in creative usage of uniface possibilities)

2 Comments

  1. Just put a Candidate Key on it?


    Author: Theo Neeskens (tneeskens@itblockz.nl)
  2. ... thanks for the tip, Theo.

    My colleague had problems when he copied the datasets by proccode;
    perhaps nothing what a set $occcheck could not fix.

     

    But we started with half of a code and had a step-by-step improvement.

     

    No excuses, just an explanation.

     


    Author: ulrich-merkel (ulrichmerkel@web.de)