X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AD0235E4813 for ; Tue, 7 Sep 2004 18:35:57 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85781-02 for ; Tue, 7 Sep 2004 17:35:53 +0000 (GMT) Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by svr1.postgresql.org (Postfix) with ESMTP id C4A3D5E4805 for ; Tue, 7 Sep 2004 18:35:52 +0100 (BST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) id 1C4jsm-000KNN-0U; Tue, 07 Sep 2004 17:35:52 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id B08FC16477; Tue, 7 Sep 2004 18:35:51 +0100 (BST) Message-ID: <413DF177.1060407@archonet.com> Date: Tue, 07 Sep 2004 18:35:51 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: oliverp21@free.fr Cc: pgsql-sql@postgresql.org Subject: Re: Problem with returning setof record References: <1094577194.413dec2a05bc4@imp1-q.free.fr> In-Reply-To: <1094577194.413dec2a05bc4@imp1-q.free.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=MAILTO_TO_SPAM_ADDR X-Spam-Level: * X-Archive-Number: 200409/45 X-Sequence-Number: 18891 oliverp21@free.fr wrote: > Hello, > > Here is a simple function I created for a test. > > create function ttt() returns setof record as ' > When I try to use it, it returns to me : > > select ttt(); > set-valued function called in context that cannot accept a set > : PL/pgSQL function "ttt" line 5 at return next > > Anyone has an idea ? You need to treat it like a table: SELECT * FROM ttt(); Also, I'm not sure you can return a setof anonymous record types (unless you can specify the structure in the select). Try CREATE FUNCTION...RETURNS SETOF utilisateurs.menus If there's no appropriate table you can use CREATE TYPE to create a structure. -- Richard Huxton Archonet Ltd