pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedtable as field type??
3+ messages / 3 participants
[nested] [flat]
* table as field type??
@ 2000-10-03 14:59 David Diller <ddiller@bbn.com>
0 siblings, 1 reply; 3+ messages in thread
From: David Diller @ 2000-10-03 14:59 UTC (permalink / raw)
To: pgsql-sql
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);
although the following doesn't work: create table bar2 (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)?
Thanks,
David
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: table as field type??
@ 2000-10-03 15:51 Tod McQuillin <devin@spamcop.net>
parent: David Diller <ddiller@bbn.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tod McQuillin @ 2000-10-03 15:51 UTC (permalink / raw)
To: David Diller <ddiller@bbn.com>; +Cc: pgsql-sql
On Tue, 3 Oct 2000, David Diller 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.
--
Tod McQuillin
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: table as field type??
@ 2000-10-03 16:16 bmccoy@chapelperilous.net
parent: Tod McQuillin <devin@spamcop.net>
0 siblings, 0 replies; 3+ messages in thread
From: bmccoy@chapelperilous.net @ 2000-10-03 16:16 UTC (permalink / raw)
To: Tod McQuillin <devin@spamcop.net>; +Cc: David Diller <ddiller@bbn.com>; 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.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2000-10-03 16:16 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-10-03 14:59 table as field type?? David Diller <ddiller@bbn.com>
2000-10-03 15:51 ` Tod McQuillin <devin@spamcop.net>
2000-10-03 16:16 ` bmccoy@chapelperilous.net
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox