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:
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,
recordis a pseudo-type. Note how pseudo-types are absent from this list in the manual: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.