Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A416A476548 for ; Mon, 14 Oct 2002 10:16:50 -0400 (EDT) Received: from matrix.login-solutions.de (matrix.login-solutions.de [194.97.151.9]) by postgresql.org (Postfix) with ESMTP id 1A0EA47656B for ; Mon, 14 Oct 2002 10:16:50 -0400 (EDT) Received: from heikodell (gateas.kirschner.net [194.97.151.33]) by matrix.login-solutions.de (Postfix) with ESMTP id 592EDD926 for ; Mon, 14 Oct 2002 14:17:32 +0200 (CEST) Content-Type: text/plain; charset="us-ascii" From: Heiko Stoermer Organization: Login & Solutions AG To: pgsql-sql@postgresql.org Subject: Stored procedure returning row or resultset Date: Mon, 14 Oct 2002 16:22:54 +0200 X-Mailer: KMail [version 1.4] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200210141622.54638.heiko.stoermer@login-solutions.de> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/146 X-Sequence-Number: 9863 Hello, I'm trying to achieve the following with pl/pgsql in postgres 7.2: I need a stored procedure proc() that calculates values for some fields a = f1() b = a + f2() c = b + f3() and returns the tuple (a,b,c) as a rowtype, so that "select proc()" produces a "normal" resultset that can be used in an application. I know of course that I could write out SELECT (f1()) AS a (f1() + f()) AS b (f1() + f2() + f3()) AS c ... in plain SQL and create a view on that, but the problem is that f1(), f2(), f3() are complex and expensive computations that I want to run only once. In the example I would call f1() three times, which is inacceptable. Is there a way to accomplish this? I have tried around quite a bit, but I cannot find out the correct syntax . Thank you, Heiko Stoermer -- Heiko Stoermer Diplom-Informatiker (FH) Login & Solutions AG Tel.: +49-821-2488-0 http://www.login-solutions.de