Re: casting BOOL to somthng
От | Michael Glaesemann |
---|---|
Тема | Re: casting BOOL to somthng |
Дата | |
Msg-id | 4B1E87BC-FB36-11D8-A2A0-000A95C88220@myrealbox.com обсуждение исходный текст |
Ответ на | casting BOOL to somthng (sad <sad@bankir.ru>) |
Ответы |
Re: casting BOOL to somthng
|
Список | pgsql-sql |
On Aug 31, 2004, at 6:06 PM, sad wrote: > why BOOL can not be casted to TEXT > ....nevertheless BOOL has a textual (output) representation 't' and > 'f' letters > why not to use this fact to define cast to TEXT ? I'm not sure of the reason why there isn't a built-in cast from boolean to text, though I'm not a big fan of casts in general so it doesn't really bother me too much. If this is something you desire, I believe you can use CREATE CAST to make your own cast from boolean to text. test=# select true::text; ERROR: cannot cast type boolean to text create or replace function bool_to_text (boolean) returns text strict language sql as ' select case when$1 then \'t\' else \'f\' end; '; create cast (boolean as text) with function bool_to_text(boolean) as assignment; test=# select true::text; text ------ t (1 row) You can find more information at <http://www.postgresql.org/docs/current/static/sql-createcast.html> Hope this helps! Michael Glaesemann grzm myrealbox com
В списке pgsql-sql по дате отправления: