Re: [GENERAL] constant column value in view with union

Поиск
Список
Период
Сортировка
От Wim Ceulemans
Тема Re: [GENERAL] constant column value in view with union
Дата
Msg-id 387C9321.6497B3C1@nice.be
обсуждение исходный текст
Ответ на constant column value in view with union  (Sarah Officer <officers@aries.tucson.saic.com>)
Список pgsql-general
Sarah Officer wrote:
>
> I am converting some Oracle stuff to Postgres (or attempting to
> convert it :) ), and I'm having trouble with my views.  I have
> figured out the syntax difference between Oracle & Postgres, I
> think, but Postgres doesn't seem to know the type of a constant text
> column.  How can I make this work?
>
> The view is something like this:
>
> create view Foo as
>   select a, b, c, 'OK' as status
>   from table1
>   where ...
> union
>   select a, b, c, 'BAD' as status
>   from table1
>   where ...
>

select a, b, c, 'OK'::varchar(3) as status ...

Concerning the union:

1. create separate views with the same structure
2. use a select of the form:

select a, b, c, status from view1 where ... union select a, b, c, status
from view2 where ...

Regards
Wim

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

Предыдущее
От: yura
Дата:
Сообщение: Re[2]: [GENERAL] case-insensitive like operator
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [GENERAL] How do you live without OUTER joins?