Re: Function's final statement must be a SELECT

From: "Premil Agarwal" <preagarw(at)gmail(dot)com>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org, pgsql-admin(at)postgresql(dot)org
Subject: Re: Function's final statement must be a SELECT
Date: 2008-05-14 20:47:55
Message-ID: 92aa956e0805141347w2b6f803bq4540c8aa910915e0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-interfaces

Great !!! COALESCE() does the job for me.

( BTW, replacing "SQL" by "PLPGSQL " still gets the same error ..... )

Thanks a lot Alvaro !!!

On Wed, May 14, 2008 at 4:36 PM, Alvaro Herrera <alvherre(at)commandprompt(dot)com>
wrote:

> Premil Agarwal escribió:
> > I am trying to write a function in PgAdmin 1.8.2 for postgres 8.3. The
> > function should check the input parameter for NULL. If its NULL then
> > function should return 'Auto' otherwise return the input as such.
>
> >
> > CREATE FUNCTION check_for_null( inp character varying) RETURNS character
> > varying AS $$
> [...]
> > $$ LANGUAGE SQL;
>
> ^^^
>
> There's your problem. Try using PLPGSQL instead.
>
> In any case, you can do this with COALESCE() and it's much easier.
>
> --
> Alvaro Herrera
> http://www.CommandPrompt.com/
> The PostgreSQL Company - Command Prompt, Inc.
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Dave Page 2008-05-14 20:49:24 Re: [INTERFACES] Function's final statement must be a SELECT
Previous Message Premil Agarwal 2008-05-14 20:38:31 Re: [INTERFACES] Function's final statement must be a SELECT

Browse pgsql-interfaces by date

  From Date Subject
Next Message Dave Page 2008-05-14 20:49:24 Re: [INTERFACES] Function's final statement must be a SELECT
Previous Message Premil Agarwal 2008-05-14 20:38:31 Re: [INTERFACES] Function's final statement must be a SELECT