Thread: composite type in a table

composite type in a table

From
Date:
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@fwshackelford.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