[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: "storing" a calculated value in plsql function ?
From:       Pavel Stehule <pavel.stehule () gmail ! com>
Date:       2019-08-30 12:21:01
Message-ID: CAFj8pRAJ5W1XVNTTdGdPG1G2pZbw=YsHeeVVP7x3BOTiaF+W3A () mail ! gmail ! com
[Download RAW message or body]

p=C3=A1 30. 8. 2019 v 12:48 odes=C3=ADlatel stan <stanb@panix.com> napsal:

> I have created a function (PLSQL) that does a complex select with joins o=
n
> 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_GU=
CS

Regards

Pavel Stehule

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

[Attachment #3 (text/html)]

<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" \
class="gmail_attr">pá 30. 8. 2019 v  12:48 odesílatel stan &lt;<a \
href="mailto:stanb@panix.com">stanb@panix.com</a>&gt; napsal:<br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">I have created a function (PLSQL) that does a \
complex select with joins on various<br> tables and views, and returns a table.<br>
<br>
In the resultant table, I have raw data, and adjusted data. The adjusted data i<br>
all adjusted by a common factor, which is calculated in the select. Presently, I<br>
calculate this same adjustment factor several times in the select.<br>
<br>
Is there a way to reference this value, multiple times, once it is calculated? Or<br>
would I have to create a 2nd select that calculates this adjustment factor, and<br>
stores it in a PLSQL variable&lt; and if I do that, can I reference this stored \
value<br> in the select?<br></blockquote><div><br></div><div>you can use custom \
configuration values like global variables</div><div><br></div><div> <a \
href="https://wiki.postgresql.org/wiki/Variable_Design#PostgreSQL_User-Defined_GUCS">h \
ttps://wiki.postgresql.org/wiki/Variable_Design#PostgreSQL_User-Defined_GUCS</a></div><div><br></div><div>Regards</div><div><br></div><div>Pavel \
Stehule<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br>
-- <br>
&quot;They that would give up essential liberty for temporary safety deserve<br>
neither liberty nor safety.&quot;<br>
                                                                        -- Benjamin \
Franklin<br> <br>
<br>
</blockquote></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic