How to pass parameters qry.filter Delphi

1

I need to filter data from a grid, but I need to pass by parameter. if it is necessary to return all the data.  I always do the following to show all the data in the Grid Example:

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

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

    
asked by anonymous 22.09.2017 / 14:25

1 answer

1

I was able to solve it as follows

 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;

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

    
22.09.2017 / 15:54