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

From Trevor Talbot
Subject Re: help w/ SRF function
Date
Msg-id 90bce5730709180224t7ec2f50h8368501e972f25f1@mail.gmail.com
Whole thread Raw
In response to Re: help w/ SRF function  (Ow Mun Heng <Ow.Mun.Heng@wdc.com>)
Responses Re: help w/ SRF function
List pgsql-general
On 9/17/07, Ow Mun Heng <Ow.Mun.Heng@wdc.com> wrote:

> > > CREATE OR REPLACE FUNCTION foo_func(fromdate timestamp, todate
> > > timestamp, code text)

> > > LANGUAGE 'sql' IMMUTABLE STRICT;

> > But If I were to use ALIASINg, I get an error
> >
> > eg: DECLARE
> >   DECLARE
> >     fromdate ALIAS for $1;
> >     todate ALIAS for $2;
> >     code ALIAS for $3;
> >
> >
> > ERROR:  syntax error at or near "ALIAS"
> > LINE 5:     fromdate ALIAS for $1;

> anyone knows how come I can't use the reference fromdate/todate etc or
> use aliases but have to resort to using $1/$2 etc?

You seem to be confusing SQL with PL/pgSQL.  If you want variables,
aliases, flow control etc instead of a simple macro, you need to use a
procedural language.

http://www.postgresql.org/docs/8.2/static/xfunc-sql.html
http://www.postgresql.org/docs/8.2/static/plpgsql.html

pgsql-general by date:

Previous
From: "Filip Rembiałkowski"
Date:
Subject: Re: keeping 3 tables in sync w/ each other
Next
From: "Filip Rembiałkowski"
Date:
Subject: Re: For index bloat: VACUUM ANALYZE vs REINDEX/CLUSTER