Re: help w/ SRF function - Mailing list pgsql-general

From Ow Mun Heng
Subject Re: help w/ SRF function
Date
Msg-id 1190181985.31628.47.camel@neuromancer.home.net
Whole thread Raw
In response to Re: help w/ SRF function  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
List 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.

pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: help w/ SRF function
Next
From: Dave Page
Date:
Subject: Re: Version 8.2.5 for Windows doesn't startup normally after upgrading from 8.2.4