Skip site navigation (1) Skip section navigation (2)

Re: composite type and domain

From: Scott Bailey <artacus(at)comcast(dot)net>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: composite type and domain
Date: 2009-05-29 02:37:51
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Grzegorz Jaśkiewicz wrote:
> 2009/5/27 Scott Bailey <artacus(at)comcast(dot)net>:
>> Who said anything about the application level?
> can you give an example please ?

Did you read the article I sent you earlier? I'm doing almost the exact 
same thing you are doing save the bytea field. I create a timespan 
composite type that has a start and end times.

But instead of doing casts and using a domain catch any errors like you 
are trying to do, I'm using constructors to return a timespan. The 
signature for the constructors look like so:
timespan(timestamp, timestamp)
timespan(timestamp, numeric)
timespan(timestamp, interval)
timespan(varchar, varchar)
And the constructors do the work of making sure that the start time 
always comes before the end time.

Anyhow read the article, it has all the examples you need.

In response to


pgsql-general by date

Next:From: Yasser IdrisDate: 2009-05-29 03:52:56
Subject: Re: Transaction settings: nowait
Previous:From: Adrian KlaverDate: 2009-05-29 02:21:00
Subject: Re: Debugging pgsql function date error

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group