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 1nyaKM-0002oM-4u for pgsql-general@arkaria.postgresql.org; Tue, 07 Jun 2022 14:37:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nyaKK-0004is-5A for pgsql-general@arkaria.postgresql.org; Tue, 07 Jun 2022 14:37:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nyaKJ-0004ii-MD for pgsql-general@lists.postgresql.org; Tue, 07 Jun 2022 14:36:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nyaKD-0002d3-Or for pgsql-general@lists.postgresql.org; Tue, 07 Jun 2022 14:36:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 257EaqKx1100022; Tue, 7 Jun 2022 10:36:52 -0400 From: Tom Lane To: =?UTF-8?B?0KY=?= cc: =?UTF-8?B?cGdzcWwtZ2VuZXJhbA==?= Subject: Re: =?UTF-8?B?U1FMIHN0YXRlOiA0MjYwMS4gRXhlY3B0aW9uIGhhbmRsaW5nLiA=?= In-reply-to: <1654611542.501794552@f527.i.mail.ru> References: <1654611542.501794552@f527.i.mail.ru> Comments: In-reply-to =?UTF-8?B?0KY=?= message dated "Tue, 07 Jun 2022 17:19:02 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1100020.1654612612.1@sss.pgh.pa.us> Date: Tue, 07 Jun 2022 10:36:52 -0400 Message-ID: <1100021.1654612612@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?UTF-8?B?0KY=?= writes: > -- 2 -- > do $$ > begin > select p.result from dbo.func() p into v_result; > exception when SQLSTATE '42601' then > raise '42601' ; > when others then > raise 'others' ; > end ; > $$ > > --Exception is not handled. This is the question. > ERROR: "v_result" is not a known variable > LINE 3 : select p.result from dbo.func() p into v_result; This error is thrown by the plpgsql parser, so you can't trap it with "exception", any more than you could trap other syntax errors detected by the parser. (As an extreme example, you could certainly not trap it if you misspelled "exception".) regards, tom lane