Pular para o conteúdo principal

Postagem em destaque

BlackTDN :: SQL e a Teoria de Conjuntos

_Créditos das imagens: Grok ### 🚀 Você sabia? SQL e a Teoria de Conjuntos estão mais conectados do que imagina! A linguagem SQL (Structured Query Language) tem suas raízes na teoria de conjuntos, um conceito matemático que trata de coleções de objetos. Em bancos de dados relacionais, cada tabela é um conjunto de linhas (ou tuplas), e operações como SELECT, JOIN, UNION e INTERSECT são inspiradas em operações como união (∪), interseção (∩) e diferença (-). Vamos explorar como isso funciona? 👇 --- ### 🔍 Principais Operações de Conjuntos no SQL Imagine duas tabelas simples: Clientes (Conjunto A): ``` +----+-------+ | ID | Nome | +----+-------+ | 1 | Ana | | 2 | João | | 3 | Maria | +----+-------+ ``` Pedidos (Conjunto B): ``` +----+-----------+ | ID | Cliente_ID| +----+-----------+ | 1 | 1 | | 2 | 2 | | 3 | 1 | +----+-----------+ ``` #### 1. União (UNION) - O que faz: Junta tudo de A e B, sem duplicatas (A ∪ B). - Exemplo: ```sql SELECT id FROM cli...

BlackTDN :: Select * From Custom Data Table in Data Model :: userRestCrudTLPPCoreFunction :: AllToJSON

_Créditos da imagem: Gerada com auxílio do Copilot_

#### Request

```json
{
    "ClassName":"userRestCrudTLPPCoreFunction",
    "FunctionName":"dna.tech.codModelPost",
    "codModel":"TURNOVERGERALEMPRESA",
    "PageNumber":1,
    "RowspPage":10,
    "parModel":"ewogICJwYXJhbWV0ZXJzIjogWwogICAgWyIhRU1QUkVTQSEiLCInMDEnIl0sCiAgICBbIiFGSUxJQUxERSEiLCInMDEnIl0sCiAgICBbIiFGSUxJQUxBVEUhIiwiJzA4JyJdLAogICAgWyIhREFUQVJRREUhIiwiJzIwMjQwMSciXSwKICAgIFsiIURBVEFSUUFURSEiLCInMjAyNDEyJyJdLAogICAgWyIhQ0NERSEiLCInICciXSwKICAgIFsiIUNDQVRFISIsIid6JyJdLAogICAgWyIhRlVOQ0FPREUhIiwiJyAnIl0sCiAgICBbIiFGVU5DQU9BVEUhIiwiJ3onIl0KICBdCn0K"    
}
```

#### Result

```json
{
    "method": "get",
    "path": "/userRestCrudADVPL/codModel/",
    "PageNumber": 1,
    "RowspPage": 9,
    "model": "TURNOVERGERALEMPRESA",
    "table": {
        "alias": "SCGN0000AB",
        "name": "",
        "description": "",
        "index": "PERIODO",
        "items": [
            {
                "detail": {
                    "row": 1,
                    "HasError": false,
                    "key": "202401",
                    "recNo": 1,
                    "items": {
                        "codPeriodo": "202401",
                        "totalTransferenciasSaida": 583,
                        "totalTransferenciasEntrada": 582,
                        "totalFuncionariosInicioMes": 722,
                        "totalFuncionariosAdmitidos": 34,
                        "totalFuncionariosMes": 756,
                        "totalFuncionariosDemitidos": 11,
                        "totalFuncionariosFinalMes": 745,
                        "turnOverGeral": 3.12,
                        "turnOverDemissoes": 0.76
                    }
                }
            },
            {
                "detail": {
                    "row": 2,
                    "HasError": false,
                    "key": "202402",
                    "recNo": 2,
                    "items": {
                        "codPeriodo": "202402",
                        "totalTransferenciasSaida": 47,
                        "totalTransferenciasEntrada": 45,
                        "totalFuncionariosInicioMes": 739,
                        "totalFuncionariosAdmitidos": 15,
                        "totalFuncionariosMes": 754,
                        "totalFuncionariosDemitidos": 12,
                        "totalFuncionariosFinalMes": 742,
                        "turnOverGeral": 1.83,
                        "turnOverDemissoes": 0.81
                    }
                }
            },
            {
                "detail": {
                    "row": 3,
                    "HasError": false,
                    "key": "202403",
                    "recNo": 3,
                    "items": {
                        "codPeriodo": "202403",
                        "totalTransferenciasSaida": 10,
                        "totalTransferenciasEntrada": 9,
                        "totalFuncionariosInicioMes": 742,
                        "totalFuncionariosAdmitidos": 18,
                        "totalFuncionariosMes": 760,
                        "totalFuncionariosDemitidos": 13,
                        "totalFuncionariosFinalMes": 747,
                        "turnOverGeral": 2.09,
                        "turnOverDemissoes": 0.88
                    }
                }
            },
            {
                "detail": {
                    "row": 4,
                    "HasError": false,
                    "key": "202404",
                    "recNo": 4,
                    "items": {
                        "codPeriodo": "202404",
                        "totalTransferenciasSaida": 20,
                        "totalTransferenciasEntrada": 14,
                        "totalFuncionariosInicioMes": 747,
                        "totalFuncionariosAdmitidos": 28,
                        "totalFuncionariosMes": 775,
                        "totalFuncionariosDemitidos": 23,
                        "totalFuncionariosFinalMes": 752,
                        "turnOverGeral": 3.41,
                        "turnOverDemissoes": 1.54
                    }
                }
            },
            {
                "detail": {
                    "row": 5,
                    "HasError": false,
                    "key": "202405",
                    "recNo": 5,
                    "items": {
                        "codPeriodo": "202405",
                        "totalTransferenciasSaida": 5,
                        "totalTransferenciasEntrada": 3,
                        "totalFuncionariosInicioMes": 751,
                        "totalFuncionariosAdmitidos": 10,
                        "totalFuncionariosMes": 761,
                        "totalFuncionariosDemitidos": 16,
                        "totalFuncionariosFinalMes": 745,
                        "turnOverGeral": 1.73,
                        "turnOverDemissoes": 1.07
                    }
                }
            },
            {
                "detail": {
                    "row": 6,
                    "HasError": false,
                    "key": "202406",
                    "recNo": 6,
                    "items": {
                        "codPeriodo": "202406",
                        "totalTransferenciasSaida": 1,
                        "totalTransferenciasEntrada": 1,
                        "totalFuncionariosInicioMes": 744,
                        "totalFuncionariosAdmitidos": 7,
                        "totalFuncionariosMes": 751,
                        "totalFuncionariosDemitidos": 23,
                        "totalFuncionariosFinalMes": 728,
                        "turnOverGeral": 2.02,
                        "turnOverDemissoes": 1.55
                    }
                }
            },
            {
                "detail": {
                    "row": 7,
                    "HasError": false,
                    "key": "202407",
                    "recNo": 7,
                    "items": {
                        "codPeriodo": "202407",
                        "totalTransferenciasSaida": 0,
                        "totalTransferenciasEntrada": 0,
                        "totalFuncionariosInicioMes": 729,
                        "totalFuncionariosAdmitidos": 10,
                        "totalFuncionariosMes": 739,
                        "totalFuncionariosDemitidos": 10,
                        "totalFuncionariosFinalMes": 729,
                        "turnOverGeral": 1.37,
                        "turnOverDemissoes": 0.69
                    }
                }
            },
            {
                "detail": {
                    "row": 8,
                    "HasError": false,
                    "key": "202408",
                    "recNo": 8,
                    "items": {
                        "codPeriodo": "202408",
                        "totalTransferenciasSaida": 0,
                        "totalTransferenciasEntrada": 0,
                        "totalFuncionariosInicioMes": 729,
                        "totalFuncionariosAdmitidos": 0,
                        "totalFuncionariosMes": 729,
                        "totalFuncionariosDemitidos": 0,
                        "totalFuncionariosFinalMes": 729,
                        "turnOverGeral": 0,
                        "turnOverDemissoes": 0
                    }
                }
            },
            {
                "detail": {
                    "row": 9,
                    "HasError": false,
                    "key": "202409",
                    "recNo": 9,
                    "items": {
                        "codPeriodo": "202409",
                        "totalTransferenciasSaida": 0,
                        "totalTransferenciasEntrada": 0,
                        "totalFuncionariosInicioMes": 729,
                        "totalFuncionariosAdmitidos": 0,
                        "totalFuncionariosMes": 729,
                        "totalFuncionariosDemitidos": 0,
                        "totalFuncionariosFinalMes": 729,
                        "turnOverGeral": 0,
                        "turnOverDemissoes": 0
                    }
                }
            }
        ]
    },
    "hasNextPage": false,
    "TotalPages": 1
}
```

#### Ou... Request

```json
{
    "ClassName":"userRestCrudTLPPCoreFunction",
    "FunctionName":"dna.tech.codModelPost",
    "codModel":"CAMPOS",
    "PageNumber":1,
    "RowspPage":5,
    "Filter" : "X3_ARQUIVO='CTT' AND X3_CAMPO<>'' AND X3_VISUAL<>'V'"
}
```

#### Result

```json
{
    "method": "get",
    "path": "/userRestCrudADVPL/codModel/",
    "PageNumber": 1,
    "RowspPage": 5,
    "model": "CAMPOS",
    "table": {
        "alias": "SX3",
        "name": "SX3010",
        "description": "",
        "index": "X3_ARQUIVO+X3_ORDEM",
        "items": [
            {
                "detail": {
                    "row": 1,
                    "HasError": false,
                    "key": "CTT01",
                    "recNo": 25686,
                    "items": {
                        "fieldAlias": "CTT",
                        "fieldName": "CTT_FILIAL",
                        "fieldDesc": "Filial do Sistema",
                        "fieldDescEng": "System Branch",
                        "fieldDescSpa": "Sucursal del Sistema",
                        "fieldType": "C",
                        "fieldSize": 2,
                        "fieldDec": 0,
                        "fieldPicture": "",
                        "fieldCBox": ""
                    }
                }
            },
            {
                "detail": {
                    "row": 2,
                    "HasError": false,
                    "key": "CTT02",
                    "recNo": 25687,
                    "items": {
                        "fieldAlias": "CTT",
                        "fieldName": "CTT_CUSTO",
                        "fieldDesc": "Centro de Custo",
                        "fieldDescEng": "Cost Center",
                        "fieldDescSpa": "Centro de Costo",
                        "fieldType": "C",
                        "fieldSize": 9,
                        "fieldDec": 0,
                        "fieldPicture": "@!",
                        "fieldCBox": ""
                    }
                }
            },
            {
                "detail": {
                    "row": 3,
                    "HasError": false,
                    "key": "CTT03",
                    "recNo": 25688,
                    "items": {
                        "fieldAlias": "CTT",
                        "fieldName": "CTT_CLASSE",
                        "fieldDesc": "Classe",
                        "fieldDescEng": "Class",
                        "fieldDescSpa": "Clase",
                        "fieldType": "C",
                        "fieldSize": 1,
                        "fieldDec": 0,
                        "fieldPicture": "@!",
                        "fieldCBox": "1=Sintetico;2=Analitico"
                    }
                }
            },
            {
                "detail": {
                    "row": 4,
                    "HasError": false,
                    "key": "CTT04",
                    "recNo": 25689,
                    "items": {
                        "fieldAlias": "CTT",
                        "fieldName": "CTT_NORMAL",
                        "fieldDesc": "Condicao Normal",
                        "fieldDescEng": "Regular Condition",
                        "fieldDescSpa": "Condicion Normal",
                        "fieldType": "C",
                        "fieldSize": 1,
                        "fieldDec": 0,
                        "fieldPicture": "@!",
                        "fieldCBox": "0=Nenhum;1=Despesa;2=Receita"
                    }
                }
            },
            {
                "detail": {
                    "row": 5,
                    "HasError": false,
                    "key": "CTT05",
                    "recNo": 25690,
                    "items": {
                        "fieldAlias": "CTT",
                        "fieldName": "CTT_DESC01",
                        "fieldDesc": "Descricao Moeda 1",
                        "fieldDescEng": "Currency 1 Description",
                        "fieldDescSpa": "Descripcion Moneda 1",
                        "fieldType": "C",
                        "fieldSize": 40,
                        "fieldDec": 0,
                        "fieldPicture": "@!",
                        "fieldCBox": ""
                    }
                }
            }
        ]
    },
    "hasNextPage": true,
    "NextPage": 2,
    "TotalPages": 18
}
```


Comentários

Postagens mais visitadas