pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: Johnny Winn <j.winn.v@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: generated dates from record dates - suggestions
Date: Wed, 22 Aug 2012 11:49:53 +0100
Message-ID: <201208221149.53634.gary.stainburn@ringways.co.uk> (raw)
In-Reply-To: <CALBtUW7CG0HbH067jWxqwLxaJsnrCdFswKq+wYiBaMpoJRvYwQ@mail.gmail.com>
References: <201208201317.46588.gary.stainburn@ringways.co.uk>
	<201208211131.49999.gary.stainburn@ringways.co.uk>
	<CALBtUW7CG0HbH067jWxqwLxaJsnrCdFswKq+wYiBaMpoJRvYwQ@mail.gmail.com>

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 




view thread (6+ messages)

Message-ID: <201208221149.53634.gary.stainburn@ringways.co.uk>
Permalink:  ../201208221149.53634.gary.stainburn@ringways.co.uk/
Also on:    postgresql.org/message-id/201208221149.53634.gary.stainburn@ringways.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gary.stainburn@ringways.co.uk, j.winn.v@gmail.com
  Subject: Re: generated dates from record dates - suggestions
  In-Reply-To: <201208221149.53634.gary.stainburn@ringways.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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