Re: convert integer to bool implicitly

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: convert integer to bool implicitly
Дата
Msg-id 20051218185815.GB4710@kaufbach.delug.de
обсуждение исходный текст
Ответ на convert integer to bool implicitly  (Sim Zacks <sim@compulab.co.il>)
Ответы Re: convert integer to bool implicitly  (Sim Zacks <sim@compulab.co.il>)
Список pgsql-general
Sim Zacks <sim@compulab.co.il> schrieb:

> How easy would it be to write a small type extension to have integer
> automatically convert to bool?
> For example, I want an implicit conversion that 0 is false and everything
> else is true.

test=# \d foo;
      Table "public.foo"
 Column |  Type   | Modifiers
--------+---------+-----------
 val    | integer |

test=# select * from foo;
 val
-----
   0
   1
   2
   3
(4 rows)

test=# select val::bool from foo;
 val
-----
 f
 t
 t
 t
(4 rows)


> Is this C programming or can you do it with a local procedural language?

You can use regular casts.


HTH, Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

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

Предыдущее
От: Sim Zacks
Дата:
Сообщение: convert integer to bool implicitly
Следующее
От: Sim Zacks
Дата:
Сообщение: Re: convert integer to bool implicitly