Re: Function's final statement must be a SELECT

Поиск
Список
Период
Сортировка
От Premil Agarwal
Тема Re: Function's final statement must be a SELECT
Дата
Msg-id 92aa956e0805141338p1a496ecdje36e03d8805e5f51@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Function's final statement must be a SELECT  ("Dave Page" <dpage@pgadmin.org>)
Ответы Re: Function's final statement must be a SELECT
Список pgsql-interfaces
Tried that already, still the same error




On Wed, May 14, 2008 at 4:36 PM, Dave Page <dpage@pgadmin.org> wrote:
On Wed, May 14, 2008 at 9:23 PM, Premil Agarwal <preagarw@gmail.com> wrote:
> 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 $$
>     DECLARE
>         temp1 character varying := 'Auto';
>         temp2 character varying := inp;
>     BEGIN
>
>         IF temp2 IS NOT NULL THEN
>         temp1 := temp2;
>         END IF;
>
>         RETURN temp1;
>     END;
> $$ LANGUAGE SQL;
>
> When I hit 'OK' in create function window, I get following error :-
>
> ERROR: return type mismatch in function declared to return character varying
> DETAIL: Function's final statement must be a SELECT.
> CONTEXT: SQL function "check_for_null"
>
> Any suggestions why this happens ??

Choose pl/pgsql as the language, not SQL.

--
Dave Page
EnterpriseDB UK: http://www.enterprisedb.com

В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: [ADMIN] Function's final statement must be a SELECT
Следующее
От: "Premil Agarwal"
Дата:
Сообщение: Re: [ADMIN] Function's final statement must be a SELECT