Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Referential integrity in Protheus customizations

Valid key + branch context + existing reference

Preserves relationships among keys, branches and dependent records.

Referential integrity in Protheus customizationsAdvPL
01 · OVERVIEW

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.)

02 · SYNTAX

Syntax

Valid key + branch context + existing reference
03 · PRACTICAL EXAMPLE

Commented 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 Nil
Expected result

Returns 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.

BEST PRACTICES
  • 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.

Related content

REFERENCES
  1. Waterloo Ferreira da Silva. AdvPL — O Manual, versão 1.0; p. 98. Referência histórica. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha