Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

DBEval

DBEval( <bBlock>, [bFirstCondition], [bSecondCondition], [nCount], [nRecno], [lRest] ) --> Nil

Evaluates a block for records in the selected scope.

DBEvalAdvPL
01 · OVERVIEW

Overview

DBEval executes a block over records under supplied conditions and limits. It returns Nil rather than a result list. The example counts at most three test-navigation records without writing fields. The caller must define scope and order/filter state; do not hide mass updates inside a supposedly read-only callback. EDTRB identifies only an owned test table already open with the required schema and permissions; examples are not intended for standard tables. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

DBEval( <bBlock>, [bFirstCondition], [bSecondCondition], [nCount], [nRecno], [lRest] ) --> Nil

Parameters

bBlock
Code blockRequired

Per-record block.

bFirstCondition
Code blockOptional

First scope condition.

bSecondCondition
Code blockOptional

Second scope condition.

nCount
NumericOptional

Record limit.

nRecno
NumericOptional

Specific scope record.

lRest
LogicalOptional

Remaining-record processing option.

Return value

Nil; not a logical success indicator.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed331()
    Local nCounted := 0
    // Owned table only, without pending edits.
    If Select("EDTRB") > 0
        EDTRB->(DBGoTop())
        EDTRB->(DBEval({|| nCounted++},,,3))
        ConOut(cValToChar(nCounted))
    EndIf
Return Nil
Expected result

Expected count from 0 to 3 depending on data and filter; alias position changes. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check RDD, alias and pending operations. Navigation can flush updates; preserve context under the caller contract and handle errors in the complete routine.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. DBEval. TDN. Accessed on 2026-10-26.
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