someone just point me to the 'composite data types'
documentation, please... (note that this is NOT inheritance):
-- first we roll-our-own datatypes:
CREATE TABLE vol (
high int4,
wide int4,
deep int4
);
CREATE TABLE changes (
who int4,
at datetime
);
--now we incorporate those composite types in a new table
CREATE TABLE something (
info varchar(30),
munged changes, -- use the composite CHANGES type
dimensions vol, -- use composite VOLume type
other char(2)
);
\d something
Table "something"
Attribute | Type | Modifier
------------+-------------+----------
info | varchar(30) |
munged | changes |
dimensions | vol |
other | char(2) |
--here we try to utilize those composite gizmos-go-boom:
INSERT INTO something VALUES(
'whatever',100,now(),36,24,36,'zx'
);
ERROR: Attribute 'munged' is of type 'changes' but expression is of type 'int4'
You will need to rewrite or cast the expression
INSERT INTO something VALUES(
'whatever',(100,now()),(36,24,36),'zx'
);
ERROR: parser: parse error at or near ","
INSERT INTO something (info,other) VALUES( 'whatever','zx');
INSERT 937857 1
-- this works, because we avoid the composite fields altogether.
INSERT INTO something.dimensions VALUES (36,24,36);
ERROR: parser: parse error at or near "."
INSERT INTO something(dimensions) VALUES (36,24,36);
ERROR: Attribute 'dimensions' is of type 'vol' but expression is of type 'int4'
You will need to rewrite or cast the expression
update something set dimensions = (36,24,36);
ERROR: parser: parse error at or near ";"
update something set dimensions = (36,24,36)::vol;
ERROR: parser: parse error at or near "::"
select * from something;
info | munged | dimensions | other
----------+--------+------------+-------
whatever | | | zx
(1 row)
so, HOW can you use a composite type? where's the doc?
--
It is always hazardous to ask "Why?" in science, but it is often
interesting to do so just the same.
-- Isaac Asimov, 'The Genetic Code'
will@serensoft.com
http://newbieDoc.sourceforge.net/ -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!