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

From: Sarah Officer <officers(at)aries(dot)tucson(dot)saic(dot)com>
To: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] constant column value in view with union
Date: 2000-01-11 22:00:31
Message-ID: 387BA7FF.6465C6BD@aries.tucson.saic.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oh dear. The problem I mentioned here occured when I just based my
view on one select statement. When I add the union clause, I am
informed that views can't handle unions. Is there a standard
work-around? I'm afraid I was planning a couple of other views
which look at this one.

Thanks,

Sarah Officer
officers(at)aries(dot)tucson(dot)saic(dot)com

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 ...
>
> My Oracle view has 4 unions with fairly complicated where clauses.
> What I want to do in the end is
>
> select status from Foo where b = 'baz';
>
> In Oracle, the system figures out that status is a text column. In
> Postgres I am warned:
>
> NOTICE: Attribute 'alert_status' has an unknown type
> Relation created; continue
> Whey I type
>
> > \d Foo
>
> Postgres responds
>
> ERROR: typeidTypeRelid: Invalid type - oid = 0
>
> Any suggestions would be appreciated.
>
> Thanks,
>
> Sarah Officer
> officers(at)aries(dot)tucson(dot)saic(dot)com
>
> ************

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message admin 2000-01-11 22:45:56 Re: [GENERAL] How do you live without OUTER joins?
Previous Message Sarah Officer 2000-01-11 21:41:59 constant column value in view with union