The loop contains a SOQL query inside, causing it to run multiple times. This will throw a QueryException because the Account query returns more than one row.
[References: Apex Developer Guide - SOQL Queries]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit