Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3eRr-0007rI-EJ for pgsql-general@arkaria.postgresql.org; Fri, 30 Aug 2019 10:48:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i3eRp-0005OS-Rj for pgsql-general@arkaria.postgresql.org; Fri, 30 Aug 2019 10:48:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3eRp-0005M3-DY for pgsql-general@lists.postgresql.org; Fri, 30 Aug 2019 10:48:05 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i3eRn-0007CA-6E for pgsql-general@lists.postgresql.org; Fri, 30 Aug 2019 10:48:04 +0000 Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id 46KbmK5PHNz13mv for ; Fri, 30 Aug 2019 06:48:01 -0400 (EDT) Received: by panix2.panix.com (Postfix, from userid 17622) id 46KbmK4dSmz1ZVM; Fri, 30 Aug 2019 06:48:01 -0400 (EDT) Date: Fri, 30 Aug 2019 06:48:01 -0400 From: stan To: pgsql-general@lists.postgresql.org Subject: "storing" a calculated value in plsql function ? Message-ID: <20190830104801.GA15055@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Editor: gVim User-Agent: Mutt/1.12.1 (2019-06-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I have created a function (PLSQL) that does a complex select with joins on various tables and views, and returns a table. In the resultant table, I have raw data, and adjusted data. The adjusted data i all adjusted by a common factor, which is calculated in the select. Presently, I calculate this same adjustment factor several times in the select. Is there a way to reference this value, multiple times, once it is calculated? Or would I have to create a 2nd select that calculates this adjustment factor, and stores it in a PLSQL variable< and if I do that, can I reference this stored value in the select? -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin