Re: plpgsql: How to modify a field in an array of records - Mailing list pgsql-general

From Tom Lane
Subject Re: plpgsql: How to modify a field in an array of records
Date
Msg-id 30905.1562075577@sss.pgh.pa.us
Whole thread Raw
In response to plpgsql: How to modify a field in an array of records  (Dirk Mika <Dirk.Mika@mikatiming.de>)
Responses Re: plpgsql: How to modify a field in an array of records  (Dirk Mika <Dirk.Mika@mikatiming.de>)
List pgsql-general
Dirk Mika <Dirk.Mika@mikatiming.de> 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 := l_value;
> The error is ERROR: syntax error at or near "." Position: 12414 where position points to the . after the [i]. I've no
ideawhat's causing this syntax 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



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Statistics tables not being updated anymore
Next
From: Adrien Nayrat
Date:
Subject: Re: Statistics tables not being updated anymore