Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgQmP-0002Wc-8D for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Oct 2021 12:14:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgQmN-0005pk-MX for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Oct 2021 12:14:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgQmN-0005pa-CW for pgsql-hackers@lists.postgresql.org; Fri, 29 Oct 2021 12:14:39 +0000 Received: from mail.tuxteam.de ([5.199.139.25]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.92) (envelope-from ) id 1mgQmL-0002I8-1g for pgsql-hackers@postgresql.org; Fri, 29 Oct 2021 12:14:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:Content-Type:MIME-Version:Message-ID:Subject:To:Date; bh=zHoCyzquh0fXRDLgwsyGM7aeub+JKiDG+rNSaUpg/EQ=; b=SQ/h9GgfSmaOF9BR51xfwcsf97GfZUSUQO7MuG0uQE8niyO9luzVJ1q1GEhtq9sAAJd1Ud21yDyhAIzqPoEbekDa1pP3W3aMuwAYvrgLJFrTuxXcF/djZ/K5XyghH9wNLSp11xA0QKe58T8ETufKLNzLeQxAq7rsYC5046TZfZtINs6G7ElPyubsUprEWgwOv0WpF0mnhl1GFh45cIn0FuQ4cVkdvwYWPYbYs/efuhhd0OMvmLBF55R4shHzhvAWkjfSOyYTLkvobwetdEtjPHVZ6xCWoL5tyCznVCA82UO8t3ZZvlDtCSaED9fZpz5LRGwl1GAqYaSDQ9dMHRUaSg==; Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1mgQmJ-0002GU-Lu for pgsql-hackers@postgresql.org; Fri, 29 Oct 2021 14:14:35 +0200 Date: Fri, 29 Oct 2021 14:14:35 +0200 To: pgsql-hackers@postgresql.org Subject: plpgsql: can I use a variable in a DECLARE later whithin the DECLARE? Message-ID: <20211029121435.GA5414@tuxteam.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="nFreZHaLTZJo0R7j" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) From: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 :=3D 23; y int :=3D 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=C3=A1s --nFreZHaLTZJo0R7j Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAmF75asACgkQBcgs9XrR2kbF2gCfUnNaI085xCyASqjLF9saAorn iWgAmwXoeWcAeBf4OY4RF9KuhNV9C1HA =ocT2 -----END PGP SIGNATURE----- --nFreZHaLTZJo0R7j--