Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id DD2992E1382 for ; Wed, 16 Jan 2008 19:16:21 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 07952-05 for ; Wed, 16 Jan 2008 19:15:49 -0400 (AST) Received: from dukecmmtar02.coxmail.com (dukecmmtar02.coxmail.com [68.99.120.49]) by postgresql.org (Postfix) with ESMTP id 430772E2D56 for ; Wed, 16 Jan 2008 19:15:53 -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 <20080116231551.IXYI27127.dukecmmtar02.coxmail.com@[192.168.1.2]> for ; Wed, 16 Jan 2008 18:15:51 -0500 Message-ID: <478E901D.7060701@rakkar.org> Date: Wed, 16 Jan 2008 15:15:41 -0800 From: Kevin Jenkins User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: How to test/read a stored procedure that returns a boolean? 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/145 X-Sequence-Number: 29998 I wrote this function but I'm not sure how to test it in PG Admin III Query. 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 begin select COUNT(*) as num_matches 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('k'); Instead of true or false, it says ERROR: query has no destination for result data SQL state: 42601 Hint: If you want to discard the results of a SELECT, use PERFORM instead. Context: PL/pgSQL function "isusedhandle" line 3 at SQL statement If I wanted to call this query and get the boolean result in C++, using PQgetvalue, how would I get this? Thanks!