Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 95A522E0064 for ; Wed, 14 May 2008 17:23:40 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21464-07 for ; Wed, 14 May 2008 17:23:34 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ti-out-0910.google.com (ti-out-0910.google.com [209.85.142.187]) by developer.postgresql.org (Postfix) with ESMTP id 6BDBC2E004A for ; Wed, 14 May 2008 17:23:35 -0300 (ADT) Received: by ti-out-0910.google.com with SMTP id y8so39908tia.5 for ; Wed, 14 May 2008 13:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=96LVONdQ+TkB+zV67Y7d3+T9BvavuDeAB50u6FMjs4g=; b=YezOhmAtzQkcsFZ2XGVGOfoPIObnDMWAiMeJKH+CWfRLxMzCuPRPeJBzutNZVQVZBzDq3T83G6WC2jKKEgWLe49pxti8uNXgdH9K1EN7J1oHJKH7ua8XAD2c+adIE4dMH6XMrR7VuP71suG3pkpw0IOTwHwf9hyVt6fqBwkPnOI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=dnyQYq4IUm7Kq+YSYQqQbEKVo7XikPMkbLoR+ViLeT41SO+8mY0g2EGp3HuNqMBZFG8A376HHOdI8bujdw7KBR3OiMSxgSLdAz4k2AWb2gRqU9hSw/m7gFZwlu3RA/uz6d97qpMVpLFS5LClF+dYXaUbGF2Q3t6FPBILoTAlqCM= Received: by 10.150.84.10 with SMTP id h10mr1509425ybb.208.1210796613601; Wed, 14 May 2008 13:23:33 -0700 (PDT) Received: by 10.150.200.17 with HTTP; Wed, 14 May 2008 13:23:33 -0700 (PDT) Message-ID: <92aa956e0805141323y3c14fe2p4e10ba9c67637c49@mail.gmail.com> Date: Wed, 14 May 2008 16:23:33 -0400 From: "Premil Agarwal" To: pgsql-interfaces@postgresql.org, pgsql-admin@postgresql.org Subject: Function's final statement must be a SELECT MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1189_23230931.1210796613655" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200805/126 X-Sequence-Number: 29210 ------=_Part_1189_23230931.1210796613655 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 ------=_Part_1189_23230931.1210796613655 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

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
------=_Part_1189_23230931.1210796613655--