Re: casting from integer to boolean

Поиск
Список
Период
Сортировка
От Richard Broersma
Тема Re: casting from integer to boolean
Дата
Msg-id 396486430803261511y385f7eb6j7f378ac2e6ea3495@mail.gmail.com
обсуждение исходный текст
Ответ на casting from integer to boolean  (Seb <spluque@gmail.com>)
Список pgsql-general
On Wed, Mar 26, 2008 at 2:58 PM, Seb <spluque@gmail.com> wrote:
> INSERT INTO my_table (var_bool) VALUES (0);
> INSERT INTO my_table (var_bool) VALUES (1);
>
> So this results in an error.  Unfortunately, there are many more columns
> and it would be very difficult to write a regexp to replace the 0s and
> 1s with their quoted versions.  Is there any way to make such INSERT
> commands be valid?  I have no experience with CAST, so any pointers
> would be welcome.  Thanks.

INSERT INTO my_table (var_bool) VALUES ( CAST( 0 AS BOOLEAN ));
or
INSERT INTO my_table (var_bool) VALUES (0::BOOLEAN);


--
Regards,
Richard Broersma Jr.

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

Предыдущее
От: Seb
Дата:
Сообщение: casting from integer to boolean
Следующее
От: Seb
Дата:
Сообщение: Re: casting from integer to boolean