1

I'm trying to create the array of rows with ::RECORD[] or ::RECORD by hand as shown below:

SELECT ARRAY['(John,Smith)','(David,Miller)']::RECORD[];

Or:

SELECT ARRAY['(John,Smith)'::RECORD,'(David,Miller)'::RECORD];

But I got the error below:

ERROR: input of anonymous composite types is not implemented

Actually, I could run the query without ::RECORD[] or ::RECORD below but the type is TEXT[]:

SELECT ARRAY['(John,Smith)','(David,Miller)'];

So, how can I create the array of rows by hand?

1 Answer 1

3

The answer is kind of already in your question: you could use row() constructors. Demo:

select array[row('a',1,true),row('b',4,false)];
array
{"(a,1,t)","(b,4,f)"}
select pg_typeof(array[row('a',1,true),row('b',4,false)]);
pg_typeof
record[]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.