Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uWwT3-003gSa-U1 for pgsql-general@arkaria.postgresql.org; Wed, 02 Jul 2025 12:21:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uWwT1-0001wx-UQ for pgsql-general@arkaria.postgresql.org; Wed, 02 Jul 2025 12:21:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uWwT1-0001wp-Jy for pgsql-general@lists.postgresql.org; Wed, 02 Jul 2025 12:21:36 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uWwT0-005IbX-0v for pgsql-general@postgresql.org; Wed, 02 Jul 2025 12:21:35 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-32cd499007aso49058251fa.0 for ; Wed, 02 Jul 2025 05:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751458893; x=1752063693; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=OMGeoTVPiKIgWht0rzokfYnvGCQLJRbdOud8vseXRXQ=; b=BW/EYo3Uz6ZwaWNf9lHQDWvsd4Nmre3RSkPFbz//8b7eHbrhc6EIa+GJdS/Y2rhLRX ETEOYp2WUwB/XcL9hn8r1lRhebhg0kc9IWeDHpInCO1qvqpdN3XBmvmkavP9rHehXNXZ gB9FI/owKAyDgYBfjZN0KS4e2JQed9NImUV6jkNrlWXhzMKnM9eT75fxFvSn8R5jNwxc g/u1saRMe258DIW7nyjJx8Q49zGhZsnZ6WIa6sQP/h80XAKwTwg2CMwkGWd6eEvdBtDz IvYeOEWnanZFXrCtW2nzY8tXFkzTHSvLEVydxG8Plm+ztckES6QdDrUJg6RCXolmYI0f cyEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751458893; x=1752063693; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OMGeoTVPiKIgWht0rzokfYnvGCQLJRbdOud8vseXRXQ=; b=ftUWebEOl6paHZCQupD0gufk2JM6xBUWWjxtcF9f3YB7iZZAH+qYthSy2or7mw70c9 HaDTtvcBsMe7tmM3IuK8zcxPxv+yhU/h2WNoi6emSC2JpPNT4WjrttKqVj/eWhWzy1WD A9AzgJB8Vy2XNVKGzh1aXHIr426u7R26TRh5dO/VagEDpF/mUegrDCmNjBkPVgWPTzgB HWbyzKH5uZyz2du1NoyI91IpNel1gKl4+U74XEq0dTaluCjZT/nqAp4CHZSgqlg+gq3B ooD9XBw+iaFkWVgwwfliVyHcb2SLluo+xeGf58B3Etqq62iTf8q06TLC6qdFzVDQi8gm Vqsw== X-Gm-Message-State: AOJu0Yy/uagxOlmJZN0UeR8yZs7somMZuh++y7OZraWCS+EUbKwuf8wK PEa7JiMvtkjkjxayfFWN0sE2y/Y2PeeJemoOBuCmqupX9VANJHORjJmSpjWxxPpqESrty0skiC5 6vN3kJR+Th41TTlFSk13v24g3Ur+NvXXNXViJ X-Gm-Gg: ASbGncsxlXTEmuX/L8uMoZflXRCb/hjDx/OGYKR0XUgcKhpj5tbagNfkmDgKyNuY8zx FSaLiyaVeu/RzrHFPVbW0rGZ29MIPL7gm+h5ZoWsakDtaJ+Wvwe/W8WbtTwlH67+aX/1GJXC1j+ o6sjpjuq1uTV05YMZdT0GC0OlnPnEmnRbICd+3fnNPNKhm0iGvn/WHuzMe/cBWJkiFcYUf/XKca Q== X-Google-Smtp-Source: AGHT+IFdXhrdTsVddZeAe9CP2NOp3jEWm5g58oYwNaLIheLDBU4QF+AIKVQfpTR9yyB/tMUCTPQa+FNYAiIw/NlM9iA= X-Received: by 2002:a05:651c:4118:b0:32b:719f:1260 with SMTP id 38308e7fff4ca-32dfff93af1mr7470361fa.9.1751458892861; Wed, 02 Jul 2025 05:21:32 -0700 (PDT) MIME-Version: 1.0 From: Durumdara Date: Wed, 2 Jul 2025 14:21:22 +0200 X-Gm-Features: Ac12FXy2rt3Z-V3ALMwxsk_t9xHDa3kQLldjec-6zekZ42aBLUlSKJ8rKd9D7_8 Message-ID: Subject: PLPGSQL - store fetched records in array of record To: Postgres General Content-Type: multipart/alternative; boundary="00000000000025d8520638f14de6" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000025d8520638f14de6 Content-Type: text/plain; charset="UTF-8" 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 --00000000000025d8520638f14de6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello!

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

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

declare=C2=A0
=C2=A0 f record;
begin=C2=A0
=C2=A0 for f in select title, lengt= h

But if I tried to define an "array of reco= rd", I got an error message.

declare=C2=A0
=C2= =A0 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=C2=A0
=C2= =A0 f TMy_Record;
=C2=A0 R_A TMy_= Record[];

<= div>Then I can work with the data.

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

<= font face=3D"arial, sans-serif">Is there any way to avoid this? To use a &q= uot;simple untyped record" in an array without "dependencies"= ;?

= Thank you for the answer!

Best regards