Re: plpgsql: How to modify a field in an array of records

Поиск
Список
Период
Сортировка
От Dirk Mika
Тема Re: plpgsql: How to modify a field in an array of records
Дата
Msg-id 75F7E98B-BD0A-40DE-8C89-0C01BDA7EC90@mikatiming.de
обсуждение исходный текст
Ответ на Re: plpgsql: How to modify a field in an array of records  (raf@raf.org)
Список pgsql-general


--
Dirk Mika
Software Developer

mika:timing GmbH
Strundepark - Kürtener Str. 11b
51465 Bergisch Gladbach
Germany

fon +49 2202 2401-1197
dirk.mika@mikatiming.de
www.mikatiming.de

AG Köln HRB 47509 * WEEE-Reg.-Nr. DE 90029884
Geschäftsführer: Harald Mika, Jörg Mika



## How2Use
## the ChampionChip by mika:timing
## https://youtu.be/qfOFXrpSKLQ
Am 03.07.19, 01:39 schrieb "raf@raf.org" <raf@raf.org>:

    If the problem you are facing is similar in nature, you
    might be able to work around it by having a variable of
    the same type as the array elements, assign to it the
    record that you want to modify, make the modification
    in the single record variable and then assign that
    single record variable back into the array element that
    it came from.

    i.e. something like:

      declare
      a rectype[];
      r rectype;
      i  integer;
      begin
      ...
      r := a[i];
      r.field := newvalue;
      a[i] := r;
      ...

It actually works the way you suggested. Not nice, but as long as it works, it's ok ;-)

    I didn't even realise that you could have an array of records.
    I've only ever used arrays of scalar values.

Yes, if that wasn't possible, I would have had to switch to a series of Array of scalar values.

BR
Dirk





В списке pgsql-general по дате отправления:

Предыдущее
От: Dirk Mika
Дата:
Сообщение: Re: plpgsql: How to modify a field in an array of records
Следующее
От: Vijaykumar Jain
Дата:
Сообщение: multiple nodes in FDW create server statement