Search code examples
genexus

How i can use in my data provider MAX() and WHERE?


i need to return my max pedcod number that have peduf = "SP".

I try:

Tpedpro
where peduf = "SP"
max(pedcod)
{
    Pedcod = Pedcod + 1
}

Tpedpro is my transaction table. But i receive:

error src0110: Missing group start brace '{' error src0115: Invalid expression after group definition; are you trying to define a subgroup?


Solution

  • You don't have to use a DataProvider to get that value. Just use an inline formula for example in the source of a procedure:

    &MaxPedCod = max(PedCod, peduf = !"SP")
    

    If you really want to use a DataProvider, you may write this:

    Tpedpro [one]
    order (pedcod)
    where peduf = "SP"
    {
        Pedcod = Pedcod + 1
    }
    

    that would mean: get the first record where peduf = "SP" with descending order by pedcod