SqlOrder and conversion of AdvPL index expressions to SQL
SqlOrder(cIndexExpression) -> cSqlFieldsExamines conversion of an index expression for ORDER BY.
Overview
Atilio’s example passes IndexKey to SqlOrder and describes concatenated fields becoming an SQL list. This is community evidence, not a universal AdvPL-expression translator: functions, qualifiers, collation and DBMS rules need checks. It neither creates a physical index nor independently adds ORDER BY. The block uses a fixed teaching expression without changing table order or interpolating external input. (Sources: refs. 1–1.)
Syntax
SqlOrder(cIndexExpression) -> cSqlFieldsCommented example
#Include "Protheus.ch"
User Function Ed672()
// Uninvoked block: verify conversion before embedding it in SQL.
Local bConvert := {|| SqlOrder("B1_FILIAL+B1_COD")}
ConOut(ValType(bConvert))
Return NilCreates block B; B1_FILIAL, B1_COD is source-described behavior, not measured here. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Do not concatenate user-provided sort expressions. Allowlist fields and validate SQL on the target DBMS.
- 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.