Referential integrity in Protheus customizations
Valid key + branch context + existing referencePreserves relationships among keys, branches and dependent records.
Overview
The historical manual emphasizes uniqueness, references and coherent change propagation. In Protheus also review sharing, logical deletion and standard-routine rules; do not assume every rule is enforced by a physical foreign key. This example checks fictional arrays to explain an orphan without querying or changing real tables. (Sources: refs. 1–1.)
Syntax
Valid key + branch context + existing referenceCommented example
#Include "Protheus.ch"
User Function Ed490()
Local aParents := {"ED01","ED02"}
Local cParent := "ED99"
Local lValid := AScan(aParents,{|cKey| cKey == cParent}) > 0
// Reference absent from the fictional set.
ConOut(lValid)
Return NilReturns false for ED99, which is absent from the parent set. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- In-memory validation does not prevent races. Revalidate in the transactional workflow and use supported business operations.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.