Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hiJES-0007xd-CF for pgsql-general@arkaria.postgresql.org; Tue, 02 Jul 2019 13:54:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hiJDS-0007vj-Cu for pgsql-general@arkaria.postgresql.org; Tue, 02 Jul 2019 13:53:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hiJDR-0007o1-UX for pgsql-general@lists.postgresql.org; Tue, 02 Jul 2019 13:53:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hiJDP-0000lp-Jm for pgsql-general@lists.postgresql.org; Tue, 02 Jul 2019 13:53:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x62DqvPo030906; Tue, 2 Jul 2019 09:52:57 -0400 From: Tom Lane To: Dirk Mika cc: "pgsql-general@lists.postgresql.org" Subject: Re: plpgsql: How to modify a field in an array of records In-reply-to: References: Comments: In-reply-to Dirk Mika message dated "Tue, 02 Jul 2019 07:49:28 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30904.1562075577.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 02 Jul 2019 09:52:57 -0400 Message-ID: <30905.1562075577@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Dirk Mika writes: > But when I try to modify a field of a record in the array I get a syntax= error. > l_classes_array[i].field1 :=3D l_value; > The error is ERROR: syntax error at or near "." Position: 12414 where po= sition points to the . after the [i]. I've no idea what's causing this syn= tax error. Yeah, that seems like it ought to work, and ideally it would. But plpgsql doesn't currently have support for nested field-of-array-element or element-of-record-field assignments. (I've looked briefly at this in the past, and it doesn't seem impossible, but it's definitely not trivial either.) You'll have to do some kind of workaround like assigning the whole array element to a temp variable, fixing the field in the temp variable, then assigning back :-( regards, tom lane