public inbox for [email protected]  
help / color / mirror / Atom feed
From: Durumdara <[email protected]>
To: Postgres General <[email protected]>
Subject: PLPGSQL - store fetched records in array of record
Date: Wed, 2 Jul 2025 14:21:22 +0200
Message-ID: <CAEcMXhmEJjrqruc0RUSNeUiUzzCf7K_TxuUAzFZoNBi_UzQdzA@mail.gmail.com> (raw)

Hello!

I have to store some fetched records into two lists (arrays) to work with
them.

I can use the RECORD type in a FOR SELECT loop to get one row data.

declare
  f record;
begin
  for f in select title, length

But if I tried to define an "array of record", I got an error message.

declare
  R_A record[]; <---- some error

So I can't store the fetched data into an array simply.

Ok, I found a solution when I define a TYPE, and I use this:

declare
  f TMy_Record;
  R_A TMy_Record[];

Then I can work with the data.

But this means a dependency, so I can't change the TYPE without
pre-dropping the stored procedure (and without recreating after).

Is there any way to avoid this? To use a "simple untyped record" in an
array without "dependencies"?

Thank you for the answer!

Best regards
dd


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: PLPGSQL - store fetched records in array of record
  In-Reply-To: <CAEcMXhmEJjrqruc0RUSNeUiUzzCf7K_TxuUAzFZoNBi_UzQdzA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox