plpgsql: can I use a variable in a DECLARE later whithin the DECLARE?

From: <tomas(at)tuxteam(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: plpgsql: can I use a variable in a DECLARE later whithin the DECLARE?
Date: 2021-10-29 12:14:35
Message-ID: 20211029121435.GA5414@tuxteam.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

In plpgsql, i'm trying to use a variable initialised in a DECLARE in
a later initialisation expression whithin the same DECLARE:

DECLARE
x int := 23;
y int := x + 4
BEGIN
...

Experiments suggest that it works, but the docs are silent about that.
Is this a good idea, or should I be more careful and do it in a nested
block?

(For Lispers: is that a let, or a let*? ;-)

Thanks & cheers
- tomás

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2021-10-29 12:40:06 Re: when the startup process doesn't (logging startup delays)
Previous Message Daniel Gustafsson 2021-10-29 11:54:29 Re: Support for NSS as a libpq TLS backend