[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    Re: [SQL] generated dates from record dates - suggestions
From:       Gary Stainburn <gary.stainburn () ringways ! co ! uk>
Date:       2012-08-22 10:49:53
Message-ID: 201208221149.53634.gary.stainburn () ringways ! co ! uk
[Download RAW message or body]

On Tuesday 21 August 2012 13:11:06 Johnny Winn wrote:
> CREATE OR REPLACE FUNCTION get_dates(date, date, date) RETURNS TABLE(date1
> date, date2 date)
> AS $$
> DECLARE
>   date_1 DATE := NULL;
>   date_2 DATE := NULL;
> BEGIN
>
>   -- test your conditions here
>
>   RETURN QUERY SELECT date_1::date, date_2::date;
> END;
> $$
> LANGUAGE PLPGSQL;
>
> I hope this helps,
> Johnny

Johnny,

Having gone down the CASE/WHEN route and found it too clumsy I'm now looking 
at using this method.  I'm just about to start writing the function, but I'm 
wondering how I would include this is the select / view .

Gary

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic