embedded-sql
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEmbedded SQL in ADVPL/TLPP
ADVPL/TLPP 中的嵌入式 SQL
This skill covers writing SQL inside ADVPL/TLPP using blocks and their special macro expressions -- for physical table resolution, for branch filtering, for logical-deletion filtering, for safe variable binding, and for primary-key ordering. It also covers type declarations, JOIN and aggregation patterns, subqueries, and migrating legacy string-concatenation code to Embedded SQL.
BeginSQL ... EndSQL%table:TABLE%%xfilial:TABLE%%notDel%%exp:EXPRESSION%%Order:TABLE%columnTCQueryActivate this skill whenever the user is writing a new query, reviewing an existing one for correctness/safety, or converting old concatenated-string SQL to the modern BeginSQL syntax. It also covers the restrictions and gotchas of BeginSQL (no at line start, always include and filial filtering, use , close aliases) and when to use instead for INSERT/UPDATE/DELETE.
*%notDel%GetNextAlias()TCSqlExecIt does not cover general native function lookups unrelated to SQL (see ), business-process context for which tables/fields to query (see ), or generating documentation for a routine that happens to contain SQL (see ).
protheus-referenceprotheus-businessdocumentation-patterns| Reference file | Read when |
|---|---|
| reference.md | Always -- BeginSQL syntax, macro expressions, JOIN/aggregation/subquery patterns, DML via TCSqlExec, performance tips, and TCQuery migration |
本技能涵盖在ADVPL/TLPP中使用块及其特殊宏表达式编写SQL的相关内容——包括用于物理表解析的、用于分支过滤的、用于逻辑删除过滤的、用于安全变量绑定的,以及用于主键排序的。同时还涵盖类型声明、JOIN与聚合模式、子查询,以及将遗留字符串拼接代码迁移至嵌入式SQL的方法。
BeginSQL ... EndSQL%table:TABLE%%xfilial:TABLE%%notDel%%exp:EXPRESSION%%Order:TABLE%columnTCQuery当用户编写新查询、审查现有查询的正确性与安全性,或将旧的字符串拼接SQL转换为现代BeginSQL语法时,均可激活本技能。本技能还涵盖BeginSQL的限制与常见陷阱(行首不能出现、必须包含和分支过滤条件、使用、及时关闭别名),以及何时改用执行INSERT/UPDATE/DELETE操作。
*%notDel%GetNextAlias()TCSqlExec本技能不涵盖与SQL无关的通用原生函数查询(参见)、涉及待查询表/字段选择的业务流程上下文(参见),或为包含SQL的例程生成文档的相关内容(参见)。
protheus-referenceprotheus-businessdocumentation-patterns| 参考文件 | 阅读场景 |
|---|---|
| reference.md | 始终阅读——包含BeginSQL语法、宏表达式、JOIN/聚合/子查询模式、通过TCSqlExec执行DML、性能优化技巧以及TCQuery迁移相关内容 |