# Sql

> Referência e geração de SQL embarcado em ADVPL/TLPP para Protheus. Cobre BeginSQL/EndSQL, macros essenciais (%table%, %xfilial%, %notDel%, %exp%, %Order%), TCSqlExec para INSERT/UPDATE/DELETE, joins, subconsultas e anti-patterns de segurança.

- **Type:** Skill
- **Install:** `agentstack add skill-tbc-servicos-dataagile-agent-kit-sql`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [tbc-servicos](https://agentstack.voostack.com/s/tbc-servicos)
- **Installs:** 0
- **Category:** [Databases](https://agentstack.voostack.com/c/databases)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [tbc-servicos](https://github.com/tbc-servicos)
- **Source:** https://github.com/tbc-servicos/dataagile-agent-kit/tree/main/protheus/skills/sql
- **Website:** https://dataagile-agent-kit.dataagile.com.br

## Install

```sh
agentstack add skill-tbc-servicos-dataagile-agent-kit-sql
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# ADVPL SQL — SQL Embarcado no Protheus

Referência completa para integração SQL em código ADVPL/TLPP para TOTVS Protheus.

---

## Por que BeginSQL em vez de TCQuery?

Comparação de abordagens para consultas SQL em ADVPL.

Consulte a referência completa via MCP:
```
searchKnowledge({ skill: "protheus-sql", keyword: "BeginSQL TCQuery" })
```

---

## Macros Essenciais

Macros padrão: `%table%`, `%xfilial%`, `%notDel%`, `%exp%`, `%Order%`, `%noAlias%`.

Consulte a referência completa via MCP:
```
searchKnowledge({ skill: "protheus-sql", keyword: "macros" })
```

---

## Templates: SELECT

Exemplos de SELECT básico, com variável (binding seguro) e JOINs entre tabelas.

Consulte a referência completa via MCP:
```
searchKnowledge({ skill: "protheus-sql", keyword: "SELECT template" })
```

---

## TCSqlExec — INSERT / UPDATE / DELETE

Exemplos de DML (INSERT, UPDATE, DELETE lógico) com TCSqlExec.

Consulte a referência completa via MCP:
```
searchKnowledge({ skill: "protheus-sql", keyword: "TCSqlExec" })
```

---

## Funções de Suporte SQL

Referência de funções: RetSqlName, GetNextAlias, TCSqlExec, xFilial.

Consulte a referência completa via MCP:
```
searchKnowledge({ skill: "protheus-sql", keyword: "funcoes SQL" })
```

---

## Regras Críticas

Regras essenciais: sem `*` em linha inicial, sempre incluir `%notDel%` e `%xfilial%`, evitar SQL injection, fechar alias, nunca full scan.

Consulte a referência completa via MCP:
```
searchKnowledge({ skill: "protheus-sql", keyword: "regras criticas" })
```

---

## Quando usar BeginSQL vs ISAM

Decisão entre BeginSQL/EndSQL e ISAM (dbSeek/MsSeek) por cenário.

Consulte a referência completa via MCP:
```
searchKnowledge({ skill: "protheus-sql", keyword: "BeginSQL ISAM" })
```

---

## Consulta de Conhecimento

Se precisar de informação não disponível no MCP, consulte o RAG:
```
searchKnowledge({ keyword: "" })
```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [tbc-servicos](https://github.com/tbc-servicos)
- **Source:** [tbc-servicos/dataagile-agent-kit](https://github.com/tbc-servicos/dataagile-agent-kit)
- **License:** MIT
- **Homepage:** https://dataagile-agent-kit.dataagile.com.br

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-tbc-servicos-dataagile-agent-kit-sql
- Seller: https://agentstack.voostack.com/s/tbc-servicos
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
