Re: help w/ SRF function

From: Ow Mun Heng <Ow(dot)Mun(dot)Heng(at)wdc(dot)com>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: help w/ SRF function
Date: 2007-09-19 06:06:25
Message-ID: 1190181985.31628.47.camel@neuromancer.home.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 2007-09-19 at 07:57 +0200, A. Kretschmer wrote:
> am Mon, dem 17.09.2007, um 9:21:22 +0800 mailte Ow Mun Heng folgendes:
> > CREATE OR REPLACE FUNCTION foo_func(fromdate timestamp, todate
> > timestamp, code text)
> > RETURNS SETOF foo AS
> > $BODY$
> > SELECT
> > TRH.ID,
> > TRH.data1,
> > TRH.data2,
> > FROM D
> > INNER JOIN TS
> > ON TS.id = D.id
> > inner join TRH
> > on ts.id = trh.id
> > WHERE D.start_timestamp BETWEEN fromdate AND todate
> > And D.code IN (code)
> > $BODY$
> > LANGUAGE 'sql' IMMUTABLE STRICT;
> >
> > How can I go about this this? The above will fail due to missing columns
> > fromdate/todate/code.
>
> Use $1, 2 and $3 within the function-body instead fromdate, todate and
> code.

Yep.. that works as advertised.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dave Page 2007-09-19 08:00:34 Re: Version 8.2.5 for Windows doesn't startup normally after upgrading from 8.2.4
Previous Message A. Kretschmer 2007-09-19 05:57:54 Re: help w/ SRF function