Re: cast numeric to char

Поиск
Список
Период
Сортировка
От Karel Zak
Тема Re: cast numeric to char
Дата
Msg-id 20021029090327.G31118@zf.jcu.cz
обсуждение исходный текст
Ответ на Re: cast numeric to char  ("Johnson, Shaunn" <SJohnson6@bcbsm.com>)
Список pgsql-general
On Mon, Oct 28, 2002 at 10:13:02AM -0500, Johnson, Shaunn wrote:
> Yes, you cannot cast a numeric to character, but there is a function called
> to_char() that will help.
>
> Something like:
>
> planning=# select to_char(4, '0000009');
>  to_char
> ----------
>   0000004
>
> The only annoying thing is that it seems to put a blank in front of the
> string, I am not sure why.  You will probably want to trim() the results.

test=# select to_char(4, '99999999');
  to_char
-----------
         4

test=# select to_char(4, 'FM99999999');
 to_char
---------
 4

 See docs, it's better then trim() :-)

    Karel

--
 Karel Zak  <zakkr@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/

 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

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

Предыдущее
От: Christoph Dalitz
Дата:
Сообщение: Re: supplying password to psql on command line?
Следующее
От: Christoph Dalitz
Дата:
Сообщение: Re: supplying password to psql on command line?