Re: table as field type??

From: <bmccoy(at)chapelperilous(dot)net>
To: Tod McQuillin <devin(at)spamcop(dot)net>
Cc: David Diller <ddiller(at)bbn(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: table as field type??
Date: 2000-10-03 16:16:30
Message-ID: Pine.LNX.4.10.10010031215310.5979-100000@chapelperilous.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 4 Oct 2000, Tod McQuillin wrote:

> > I noticed that it's possible to have a table as a field type.
> > For example:
> > create table foo (val1 integer);
> > create table bar (val2 foo);
> >
> > val2 in table bar ends up as an int4, designed for storing an oid from
> > table foo.
> > Is there a way to perform a query on bar that will return values from table
> > foo (i.e., val1)?
>
> I didn't know you could use a table name as a type either. I thought
> something like this might join the tables:
>
> select val1 from foo, bar where bar.val2::oid = foo.oid ;
>
> But I get "ERROR: Cannot cast type 'foo' to 'oid'"
>
> You can't seem to cast an oid into a foo either.

Don't you need to use CREATE TYPE to use a new type in this fashion?

Brett W. McCoy
http://www.chapelperilous.net
---------------------------------------------------------------------------
You are going to have a new love affair.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Ansley 2000-10-03 16:17:17 RE: OID Perfomance - Object-Relational databases
Previous Message Josh Berkus 2000-10-03 16:06:02 OID Perfomance - Object-Relational databases