Re: "storing" a calculated value in plsql function ?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: stan <stanb(at)panix(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: "storing" a calculated value in plsql function ?
Date: 2019-08-30 12:21:01
Message-ID: CAFj8pRAJ5W1XVNTTdGdPG1G2pZbw=YsHeeVVP7x3BOTiaF+W3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

pá 30. 8. 2019 v 12:48 odesílatel stan <stanb(at)panix(dot)com> napsal:

> 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?
>

you can use custom configuration values like global variables

https://wiki.postgresql.org/wiki/Variable_Design#PostgreSQL_User-Defined_GUCS

Regards

Pavel Stehule

>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
> -- Benjamin Franklin
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Niels Jespersen 2019-08-30 13:00:01 Re: SSPI auth and mixed case usernames
Previous Message Magnus Hagander 2019-08-30 11:31:17 Re: SSPI auth and mixed case usernames