Ignore point in a Query

0

I'm trying to run the following Query:

select codigo from cliente where codigo ilike '%99.999.999%';

I found that by putting ilike , it would ignore everything, points and accents but I was wrong.

In my system, I have a query screen where I prefer that the user does not have to enter the points ... When he searches for a CPF for example

Detail: I use this query in a TextChanged of a TextBox

How could I do this query to ignore the points?

    
asked by anonymous 31.07.2015 / 15:08

2 answers

1

You can use the REPLACE function to remove the points. Here is an example.

REPLACE('99.999.999', '.','')
    
31.07.2015 / 15:45
2

Avoid injecting application complexity into sql querys. This makes it difficult to maintain because reusing SQL (strings) is practically 0.

The ideal serial construct of an object Cpf:

public class Cpf{

     private string _valorSemMascara;

     public string CpfComMascara {
         get{
              // retorna _valorSemMascara incluindo máscara por concatenação
          }
          set{
             // remove máscara de 'value' e atribui valor em _valorSemMascara
          }

     }

     public string CpfSemMascara {

          get{
             return _valorSemMascara;
          }
          set{
             _valorSemMascara = value;
          }
     }

}

This object would be reused in various situations within your system.

You can use it from your 'text_changed' to the point of inclusion, changes and selections.

Only in the situation you described and in a CRUD, how many times would you repeat the 'REPLACE' method in the query? What if I decide to change DBMS? Will you leave your query stuck to PostgreSql?

    
31.07.2015 / 16:05