plpgsql: can I use a variable in a DECLARE later whithin the DECLARE? - Mailing list pgsql-hackers

From
Subject plpgsql: can I use a variable in a DECLARE later whithin the DECLARE?
Date
Msg-id 20211029121435.GA5414@tuxteam.de
Whole thread Raw
Responses Re: plpgsql: can I use a variable in a DECLARE later whithin the DECLARE?  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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

Attachment

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Support for NSS as a libpq TLS backend
Next
From: Robert Haas
Date:
Subject: Re: when the startup process doesn't (logging startup delays)