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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Function's final statement must be a SELECT



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 ??

Thanks


Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group