X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0CA0E3A4784 for ; Thu, 25 Nov 2004 18:30:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58435-07 for ; Thu, 25 Nov 2004 18:29:45 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id AEB653A4689 for ; Thu, 25 Nov 2004 18:29:44 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAPITgx8001115; Thu, 25 Nov 2004 13:29:43 -0500 (EST) To: Reza Shanbehbazari Mirzaei Cc: pgsql-sql@postgresql.org Subject: Re: User defined types In-reply-to: References: Comments: In-reply-to Reza Shanbehbazari Mirzaei message dated "Sat, 20 Nov 2004 17:35:33 +0100" Date: Thu, 25 Nov 2004 13:29:42 -0500 Message-ID: <1114.1101407382@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/256 X-Sequence-Number: 19574 Reza Shanbehbazari Mirzaei writes: > I have a user define type called VALID_TIME. It is declared as follows: > CREATE TYPE VALID_TIME AS (t_s TIMESTAMP, t_e TIMESTAMP); > Once I have used this in a table declaration, is it possible to extract > parts of it, for example to only read t_s or t_e? If so, how do I do this? 8.0 supports using composite types as table columns, but prior versions don't really. In 8.0 you'd do something like create table myt (vt valid_time); select (vt).t_s from myt; or select (myt.vt).t_s from myt; The parentheses are essential --- without them, you'd have for instance select vt.t_s from myt; which looks like a reference to field t_s of table vt, not what you want. You can hack around the problem in earlier versions by creating helper functions, eg select get_t_s(vt) from myt; but it's ugly enough to make one wonder why bother with a composite type. regards, tom lane