Re: atoi-like function: is there a better way to do this?
В списке pgsql-general по дате отправления:
| От | Tom Molesworth |
|---|---|
| Тема | Re: atoi-like function: is there a better way to do this? |
| Дата | |
| Msg-id | 4F54879E.9020900@audioboundary.com обсуждение исходный текст |
| Ответ на | Re: atoi-like function: is there a better way to do this? (Chris Angelico <rosuav@gmail.com>) |
| Список | pgsql-general |
On 05/03/12 05:08, Chris Angelico wrote:
> On Mon, Mar 5, 2012 at 3:15 PM, Tom Molesworth<tom@audioboundary.com> wrote:
>> Can you use to_number() here? It sounds like something along the lines of
>> cast(to_number('0' || field::varchar, '999999999.') as int) might give the
>> behaviour you're after, and a quick test seems to indicate that it's about
>> 4x faster than the original function:
> I looked at to_number but it seems to find digits anywhere inside the
> field - to_number('12.34','99999') returns 1234, but I want it to stop
> at the decimal.
Right - that's why I included the . in the format string. Haven't done
exhaustive testing but it seemed to do what you were after.
cheers,
Tom
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера