Re: composite type and domain - Mailing list pgsql-general

From Scott Bailey
Subject Re: composite type and domain
Date
Msg-id 4A1F4A7F.3080603@comcast.net
Whole thread Raw
In response to Re: composite type and domain  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
Responses Re: composite type and domain
List pgsql-general
Grzegorz Jaśkiewicz wrote:
> 2009/5/27 Scott Bailey <artacus@comcast.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.

http://scottrbailey.wordpress.com/2009/05/19/timespan-postgresql/

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Debugging pgsql function date error
Next
From: Yasser Idris
Date:
Subject: Re: Transaction settings: nowait