Bem resumindo:

select to_ascii('CRÉD', 'LATIN1')

Se o server_encoding for win1252 retorna 'CRED'
Mas se o server encoding for UTF8 retorna 'CRA D', Neste caso deveria se
usar a função convert :

select to_ascii(convert('CRÉD', 'utf8', 'LATIN1'), 'latin1'), mas aí
acontece um erro, pq to_ascii espera um tipo texto e convert agora retorna
bytea.

Aí não sei como resolver, acho que esta mudança deve ter acontecido no 8.3.


Em 25/03/08, Silfar Goulart <[EMAIL PROTECTED]> escreveu:
>
> Osvaldo a fundo convert mudou no postgresq 8.3
>
> Agora o retorno é do tipo bytea.
>
>
> http://pgdocptbr.sourceforge.net/pg80/datatype-binary.html#DATATYPE-BINARY-TABLE
>
> "A letra a sem acento é mostrada literalmente, mas as letras acentuadas
> são mostradas através de valores octais. 
> [2]<http://pgdocptbr.sourceforge.net/pg80/datatype-binary.html#FTN.AEN5424>
> [3]<http://pgdocptbr.sourceforge.net/pg80/datatype-binary.html#FTN.AEN5426>
>
> => \!chcp 1252
>
> Active code page: 1252
> => SELECT cast('aàáâã' AS bytea);
>
>
>        bytea
> -------------------
>
>  a\340\341\342\343
> (1 linha)"
>
>
> Agora como transformar \340  em 'a' é que é o caso.
>
>
>
>
> Em 17/03/08, Osvaldo Rosario Kussama <[EMAIL PROTECTED]> escreveu:
> >
> > Silfar Goulart de Castro escreveu:
> >
> > >>>> Qual o resultado de:
> > >>>> SELECT ID_TITULAR , NM_TITULAR, SIGLA_SOC, TP_PESSOA
> > >>>> FROM TITULAR T
> > >>>> WHERE (to_ascii(convert(t.nm_titular, 'LATIN1'), 'LATIN1') =
> > >>>> to_ascii(convert(:par, 'LATIN1'), 'LATIN1'))
> > >>>> ORDER BY NM_TITULAR;
> > >
> > > SELECT ID_TITULAR , NM_TITULAR, SIGLA_SOC, TP_PESSOA
> > >  FROM TITULAR T
> > >  WHERE (to_ascii(convert(t.nm_titular, 'LATIN1'), 'LATIN1') =
> > >  to_ascii(convert('Sérgio', 'LATIN1'), 'LATIN1'))
> > >  ORDER BY NM_TITULAR;
> > >
> > >
> > > ERROR:  function convert(character varying, unknown) does not exist
> > > LINE 3:  WHERE (to_ascii(convert(t.nm_titular, 'LATIN1'), 'LATIN1')
> > ...
> > >                          ^
> > > HINT:  No function matches the given name and argument types. You
> > might need to add explicit type casts.
> > >
> >
> >
> >
> > Não sei qual versão você está utilizando.
> > Na versão 8.2 o comando "\df+ convert" do psql informa:
> >
> > Lista de funções
> >   Esquema   = pg_catalog
> >   Nome   = convert
> >   Tipo de dado do resultado = text
> >   Tipos de dado do argumento = text, name
> >   Dono   = postgres
> >   Linguagem = internal
> >   Código fonte = pg_convert
> >   Descrição  = convert string with specified destination encoding name
> >
> > e aqui funciona (o banco está em UTF8):
> > bdteste=# SELECT *
> > bdteste-#  FROM pessoa
> > bdteste-#  WHERE (to_ascii(convert(nome, 'LATIN1'), 'LATIN1') =
> > bdteste(#  to_ascii(convert('Cia Consórcio', 'LATIN1'), 'LATIN1'))
> > bdteste-# ;
> >   id_pessoa |     nome
> > -----------+---------------
> >           3 | Cia Consórcio
> > (1 registro)
> >
> >
> > Osvaldo
> >
> > _______________________________________________
> > pgbr-geral mailing list
> > [email protected]
> > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> >
>
>
>
> --
> Silfar Goulart




-- 
Silfar Goulart
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a