I am currently working on a function in Postgres. I have the function working, but I need to add a loop inside the json_build_array() function to add multiple of what is inside the array. This is what I currently have:
select jsonb_build_object('start', jsonb_build_object(
'inv', json_build_array(
for i in select * from generate_series(1,5) loop
jsonb_build_object(...
end loop
But I get an error saying:
Syntax error at or near "for".