Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id B200A1337B7D for ; Fri, 28 Jan 2011 21:24:29 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 07201-04 for ; Sat, 29 Jan 2011 01:24:24 +0000 (UTC) X-Greylist: delayed 00:08:13.57385 by SQLgrey-1.7.6 Received: from newserver.jfcomputer.com (unknown [76.14.161.106]) by mail.postgresql.org (Postfix) with ESMTP id 511B91337B7A for ; Fri, 28 Jan 2011 21:24:22 -0400 (AST) Received: from localhost (unknown [127.0.0.1]) by newserver.jfcomputer.com (Postfix) with ESMTP id 2C2491234B for ; Sat, 29 Jan 2011 01:16:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at site Received: from newserver.jfcomputer.com ([127.0.0.1]) by localhost (linux-jfp8.site [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zPUWtB6D9sUD for ; Fri, 28 Jan 2011 17:16:05 -0800 (PST) Received: from linux-desktop.localnet (unknown [192.168.1.108]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johnf@jfcomputer.com) by newserver.jfcomputer.com (Postfix) with ESMTPSA id 0B4C412239 for ; Fri, 28 Jan 2011 17:16:05 -0800 (PST) From: John Fabiani Organization: J.F. Computer Solutions To: pgsql-sql@postgresql.org Subject: something simple but I can't Date: Fri, 28 Jan 2011 17:16:04 -0800 User-Agent: KMail/1.13.5 (Linux/2.6.34.7-0.5-desktop; KDE/4.4.4; i686; ; ) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201101281716.04534.johnf@jfcomputer.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.107 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RDNS_NONE=0.793 X-Spam-Level: X-Archive-Number: 201101/114 X-Sequence-Number: 35061 Hi guys, I trying to return a 0.00 from a function it there are no records found else return the amount. create or replace function danmeans_getpayments(text) returns numeric as $BODY$ declare invoice_num ALIAS FOR $1; _paidamt numeric; BEGIN select sum(aropen_paid) into _paidamt FROM public.aropen where aropen_applyto is not null and (aropen_applyto = $1) ; IF (FOUND) THEN RETURN _paidamt ; END IF; RETURN 0.00 ; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE COST 100 But all I get is either a blank or the amount paid. What am I doing wrong??? Johnf