I tried to declare the local variable value with RECORD[] type in a DO statement as shown below:
DO $$
DECLARE
value RECORD[];
BEGIN
END
$$;
But, I got the error below:
ERROR: variable "value" has pseudo-type record[]
I referred to these questions and answers but I could not solve the error:
postgresql cannot create table with pseudo-type record
Postgresql: How to work around pseudo-type record errors
Actually, I could declare value with RECORD or INT[] type without error as shown below:
DO $$
DECLARE
value RECORD;
BEGIN
END
$$;
DO $$
DECLARE
value INT[];
BEGIN
END
$$;
So, how can I declare value with RECORD[] type?
Like the error message says, record is a pseudo-type. Note how pseudo-types are absent from this list in the manual:
Arrays of any built-in or user-defined base type, enum type, composite type, range type, or domain can be created.
Some pseudo-types don't make sense as element type of an array to begin with. And record[] is just not implemented to be declared in PL/pgSQL. That might change in the future, but don't hold your breath. I don't think it's very useful. And neither does Tom Lane.
I have never had the need for something like record[]. Maybe you can use an array based on a registered row type. But, typically, there is a better way. You would have do disclose what you are trying to achieve.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With