Re: Function's final statement must be a SELECT

"Premil Agarwal" <[email protected]>
Newsgroups gmane.comp.db.postgresql.admin,gmane.comp.db.postgresql.interfaces
Message-ID <[email protected]>
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 <[email protected]>
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.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.