How to pass Delphi qry.filter parameters

Asked

Viewed 621 times

1

I need to filter data from a grid, but I need to pass by parameter. in case all data needs to be returned. Always do as follows to show all data in Grid Example:

SELECT FROM TABELA A
WHERE (A.NUM = :parâmetros) OR (:parâmetros = 0)

but how can I do it this way in: filter := 'num = :paramentro' or (:paramentro = 0)

  • 1

    Remind me that "filter" has to be mounted filter := 'num = 1234; "

  • @Motta as it is, I ended up using with Like and when I want to return all data to the grid step one '%'

1 answer

1


I was able to solve it this way

 qryLista.Filter := 'UPPER(CSITUCTMNF)     LIKE'+ UpperCase(QuotedStr(situcacao))+
                     'AND UPPER(CTPDCCTMNF) LIKE'+ UpperCase(QuotedStr(documento))+
                     'AND UPPER(CTIPOCTMNF) LIKE'+ UpperCase(QuotedStr(tipo));
  qryLista.Filtered := True;

the variables situation, document and start type them with '%', if you pass another value the variable is as follows variavel := '%'+ dados + '%';. If I change the parameter for everyone variavel := '%'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.