How to put db2 query result into an array in shell script?

Hello,

Can someone please advise me how to put the db2 query reult into an array?

For example, the query reults are:
string A
string B
string C

Then how do I put them into array[0]=string A
array[1]=string B
array[2]=string C

Thank you very much,
From a new learnner.

You can pipe it like
i=0
DB_Query | while read L; do Array[$i]="$L"; ((i++)); done
# Checking:
for ((i=0; i<${#Array[@]}; i++))
do echo "$i - ${Array[$i]}"
done

Frans, that dosn't work as while loop is run in a subshell.

This should do it:

while read L; do Array[$((i++))]="$L"; done < <(DB_Query)
# Checking:
for ((i=0; i<${#Array[@]}; i++))
do
   echo "$i - ${Array[$i]}"
done