Skip site navigation (1) Skip section navigation (2)

Re: Function's final statement must be a SELECT

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Premil Agarwal <preagarw(at)gmail(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:36:21
Message-ID: 20080514203621.GI9838@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-interfaces
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

Responses

pgsql-admin by date

Next:From: Premil AgarwalDate: 2008-05-14 20:38:31
Subject: Re: [INTERFACES] Function's final statement must be a SELECT
Previous:From: Dave PageDate: 2008-05-14 20:36:13
Subject: Re: [INTERFACES] Function's final statement must be a SELECT

pgsql-interfaces by date

Next:From: Premil AgarwalDate: 2008-05-14 20:38:31
Subject: Re: [INTERFACES] Function's final statement must be a SELECT
Previous:From: Dave PageDate: 2008-05-14 20:36:13
Subject: Re: [INTERFACES] Function's final statement must be a SELECT

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group