I make a request from Java:
select array_agg(symptoms.*) from symptoms where sickId=1;
I get the result:
{(1,"Ларингит острый",t,t,t,t,t,t,t,t,f,f,f,f,f,f,f,f)}
Then I try to put it all into an array of objects in Java:
Object[] myField = (Object[]) resultSet.getArray("array_agg").getArray();
He puts the whole result in the first cell of the array. And I need it to split the result into cells. For example:
myField[0] = 1, myField[1]="Ларингит острый", myField[2] = true etc
How to fix?
I'm trying to get a string from PostgreSQL with a specific index and convert it to an array of Object in Java.
Maybe you can change your query to return the columns values each one in a row using
unnest(see doc 9.18. Array Functions and Operators). Check this example:Given you have a table like:
When you select your columns as an array and apply
unnestfunction to show each column in a row.Result:
Then you can get this results like a array and interact with it