Re: help w/ SRF function

From: Ow Mun Heng <Ow(dot)Mun(dot)Heng(at)wdc(dot)com>
To: Trevor Talbot <quension(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: help w/ SRF function
Date: 2007-09-24 03:48:01
Message-ID: 1190605681.17050.13.camel@neuromancer.home.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2007-09-18 at 02:24 -0700, Trevor Talbot wrote:
> On 9/17/07, Ow Mun Heng <Ow(dot)Mun(dot)Heng(at)wdc(dot)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.htmll

Thanks. I've moved from SQL to plpgsql now. Thanks to your pointers and
ppl in IRC.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-09-24 03:57:24 Re: Out of Memory - 8.2.4
Previous Message Ow Mun Heng 2007-09-24 03:43:41 Re: Migration from PervasiveSQL