pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
User defined types 2+ messages / 2 participants [nested] [flat]
* User defined types @ 2004-11-20 16:35 Reza Shanbehbazari Mirzaei <mirzaei@stud.ntnu.no> 0 siblings, 1 reply; 2+ messages in thread From: Reza Shanbehbazari Mirzaei @ 2004-11-20 16:35 UTC (permalink / raw) To: pgsql-sql Hello: 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? Thank you. -Reza ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: User defined types @ 2004-11-25 18:29 Tom Lane <tgl@sss.pgh.pa.us> parent: Reza Shanbehbazari Mirzaei <mirzaei@stud.ntnu.no> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2004-11-25 18:29 UTC (permalink / raw) To: Reza Shanbehbazari Mirzaei <mirzaei@stud.ntnu.no>; +Cc: pgsql-sql Reza Shanbehbazari Mirzaei <mirzaei@stud.ntnu.no> 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 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-11-25 18:29 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2004-11-20 16:35 User defined types Reza Shanbehbazari Mirzaei <mirzaei@stud.ntnu.no> 2004-11-25 18:29 ` Tom Lane <tgl@sss.pgh.pa.us>
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