Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 5E12E2E2D42 for ; Wed, 16 Jan 2008 19:50:59 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 34004-05 for ; Wed, 16 Jan 2008 19:50:53 -0400 (AST) Received: from dukecmmtar02.coxmail.com (dukecmmtar02.coxmail.com [68.99.120.49]) by postgresql.org (Postfix) with ESMTP id 041142E0FF9 for ; Wed, 16 Jan 2008 19:50:52 -0400 (AST) Received: from [192.168.1.2] (really [70.169.225.166]) by dukecmmtar02.coxmail.com (InterMail vM.6.01.06.01 201-2131-130-101-20060113) with ESMTP id <20080116235052.JTAX27127.dukecmmtar02.coxmail.com@[192.168.1.2]> for ; Wed, 16 Jan 2008 18:50:52 -0500 Message-ID: <478E9851.9020905@rakkar.org> Date: Wed, 16 Jan 2008 15:50:41 -0800 From: Kevin Jenkins User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 CC: pgsql-sql@postgresql.org Subject: Re: How to test/read a stored procedure that returns a boolean? References: <478E901D.7060701@rakkar.org> <29647.1200526120@sss.pgh.pa.us> In-Reply-To: <29647.1200526120@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/147 X-Sequence-Number: 30000 Thanks Tom! Also, how do I check if a language is already created so I don't load it twice? "ERROR: language "plpgsql" already exists SQL state: 42710" Here is the code fixed. /* CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'; CREATE TABLE handles ( handleID_pk serial PRIMARY KEY UNIQUE NOT NULL, userID_fk integer UNIQUE NOT NULL, handle text UNIQUE NOT NULL); CREATE TABLE disallowedHandles ( handle text UNIQUE NOT NULL); */ create or replace function IsUsedHandle(h text) returns boolean as $$ declare num_matches integer; begin num_matches := COUNT(*) from handles where handles.handle = h; return num_matches > 0; end; $$ LANGUAGE plpgsql; -- INSERT INTO handles (handle, userid_fk) VALUES ('blah', 0); select * from IsUsedHandle('blah');