Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

LastRec

LastRec() -> nRecord

Reads the last inserted record number in the current area.

LastRecAdvPL
01 · OVERVIEW

Overview

This is neither a reliable active-record count nor business-key confirmation. The reference warns that pending actions may be flushed and raise Commit error; an unopened area causes an error. The example keeps the call in an unexecuted block so the caller controls context. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

LastRec() -> nRecord

Return value

Last record number according to the RDD.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed504()
    // Evaluate only with the appropriate area and no pending writes.
    Local bLast := {|| LastRec()}
    ConOut(ValType(bLast))
Return Nil
Expected result

Prepares a block without querying the area or flushing pending actions. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Use an appropriate query for counts and distinguish logical, physical and deleted records.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. LastRec. TDN. 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