Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

RetSqlName and physical table names

Resolves SQL table names without hardcoding company suffixes.

RetSqlName and physical table namesAdvPL
01 · OVERVIEW

Overview

RetSqlName maps a logical dictionary alias to its configured physical name. Appending 010 is unsafe because company configuration varies. Name resolution does not add branch, logical-deletion or authorization filters. In joins calculate xFilial per table rather than comparing branch fields with different sharing rules. The example reads only the SB1 name in an already prepared environment and executes no query. Bind input values using the available SQL API. (Sources: refs. 1–2.)

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed628()
    // Uninvoked block; requires an environment with dictionary access.
    Local bName := {|| RetSqlName("SB1")}
    ConOut(ValType(bName))
Return Nil
Expected result

Creates block B; assumes neither SB1010 nor product access. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Physical names must not come from arbitrary user input. Resolving a table grants no record access.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Desenvolvendo queries no Protheus. Accessed on 2026-10-27.
  2. Atilio. dan-atilio/AdvPL. Maratona de Exemplos/Exemplo_421_Funcao_RetSQLName.prw. Arquivo completo consultado; adaptação editorial. 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