Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id BEFE163551F for ; Wed, 1 Apr 2009 20:32:07 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 93633-05 for ; Wed, 1 Apr 2009 20:32:04 -0300 (ADT) Received: from mx1.hub.org (mx1.hub.org [200.46.208.106]) by mail.postgresql.org (Postfix) with ESMTP id 55715635511 for ; Wed, 1 Apr 2009 20:32:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp1.islandnet.com (smtp1.islandnet.com [199.175.106.100]) by mx1.hub.org (Postfix) with ESMTP id E151C125AEA4 for ; Wed, 1 Apr 2009 20:32:03 -0300 (ADT) Received: from [199.175.106.50] (port=42373 helo=cluster.islandnet.com) by smtpout.islandnet.com with ESMTP id 1Lp9tt-0002rz-5J for pgsql-sql@postgresql.org; Wed, 01 Apr 2009 16:31:17 -0700 Received: from [24.108.1.50] (port=4770 helo=[192.168.0.193]) by cluster01.islandnet.com with ESMTPSA (TLSv1:AES256-SHA:256) id 1Lp9tt-0005GE-3a for pgsql-sql@postgresql.org; Wed, 01 Apr 2009 16:31:17 -0700 Message-ID: <49D3F948.4060908@borstad.com> Date: Wed, 01 Apr 2009 16:31:20 -0700 From: Peter Willis Reply-To: peterw@borstad.com User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: FUNCTION problem Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/7 X-Sequence-Number: 32353 Hello, I am having a problem with a FUNCTION. The function creates just fine with no errors. However, when I call the function postgres produces an error. Perhaps someone can enlighten me. --I can reproduce the error by making a test function --that is much easier to follow that the original: CREATE OR REPLACE FUNCTION test_function(integer) RETURNS SETOF RECORD AS $BODY$ DECLARE croid integer; BEGIN --PERFORM A SMALL CALCULATION --DOESNT SEEM TO MATTER WHAT IT IS SELECT INTO croid 2; --A SELECT STATEMENT OUTPUTS RECORDS (one in this case) SELECT croid,$1; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE --The call looks like the following: SELECT test_function(1); --The resulting error reads as follows: ERROR: query has no destination for result data HINT: If you want to discard the results of a SELECT, use PERFORM instead. CONTEXT: PL/pgSQL function "test_function" line 5 at SQL statement ********** Error ********** 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 "test_function" line 5 at SQL statement