Re: Trim not working (PostgreSQL 9.1.2 on Win64)

Поиск
Список
Период
Сортировка
От Edson Richter
Тема Re: Trim not working (PostgreSQL 9.1.2 on Win64)
Дата
Msg-id BLU0-SMTP197495B684B8B09E4AB21A3CFC70@phx.gbl
обсуждение исходный текст
Ответ на Re: Trim not working (PostgreSQL 9.1.2 on Win64)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Em 28/07/2012 19:41, Tom Lane escreveu:
> Edson Richter <edsonrichter@hotmail.com> writes:
>> If I do apply trim over the substring, no spaces are removed, and I
>> cannot understand why.
>> ...
>> But using the regular expression matching "^\s*" and "\s*$" works, and
>> spaces are removed:
> I think what this means is that what you say are runs of spaces are no
> such thing, but are some other whitespace character(s).  Perhaps tabs,
> or non-breaking spaces?
>
>             regards, tom lane
>
By all means, you are right.
I supposed they are spaces... at least in the original CVS file.
I've used an Hex editor, and they are character C2A0 (UTF-8) in the file.
Now, executing the following query surprises me:

select rslinha2,
        ascii(substring(rslinha2 from 3 for position('(+)' in rslinha2)-4))
   from plan_maio
  limit 1

resulted in the following:

"2. TAXA VIGILANCIA                                   (+) R$ 13,00";160

So, file_fdw converted my original spaces into character 160.
That's the reason for trim not working.

Thanks for your toughs. You led me to the right direction: when
importing data from files, not always what looks like is what it is.


Regards,

Edson Richter.


В списке pgsql-general по дате отправления:

Предыдущее
От: Edson Richter
Дата:
Сообщение: Re: Trim not working (PostgreSQL 9.1.2 on Win64)
Следующее
От: John R Pierce
Дата:
Сообщение: array_length of an empty array