composite type in a table

From: <floyds(at)4peakstech(dot)com>
To: "Pgsql-Sql" <pgsql-sql(at)postgresql(dot)org>
Subject: composite type in a table
Date: 2003-08-22 19:32:27
Message-ID: NDBBKEGJICMIMJHJEBCOEECPGNAA.floyds@4peakstech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


is there any way to use a composite type in a table?

here's an example:

say i want to create a type to hold currency:

create type currency_type as ( base_objid int, base_amt decimal,
conversion_rate decimal, converted_objid int );

i'd like to be able to define a column in a table of type currency_type:

create table currency_table ( myMoney currency_type );

unfortunately, i get:

ERROR: Attribute "mymoney" has composite type currency_type

it sure would be nice if it was as simple as this, but it isn't. what's the
easiest way to create a composite-like type that can be added to a table?

also, how does one access the internal fields of a composite type?

Regards,

Floyd Shackelford
VOICE: 334.735.9428
FAX: 702.995.6462
EMAIL: floyd(at)fwshackelford(dot)com
ICQ #: 161371538
PGP Key ID: 0x2E84F2F2
PGP Fone at private.fwshackelford.com on request

Shackelford Motto: ACTA NON VERBA - Actions, not words

Alabama State Motto: AUDEMUS JURA NOSTRA DEFENDERE - We Dare Defend Our
Rights

The Philosophy of Liberty: http://www.isil.org/resources/introduction.swf

"Just because you do not take an interest in politics doesn't mean politics
won't take an interest in you."
-- Pericles (430 B.C.)

"I cannot undertake to lay my finger on that article of the Constitution
which granted a right to Congress of expending, on objects of benevolence,
the money of their constituents...."
--James Madison

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2003-08-22 23:24:13 Delete denied?
Previous Message Stephan Szabo 2003-08-22 15:47:30 Re: [SQL] "SELECT IN" Still Broken in 7.4b