TITLE: Structure theorem of f.g. modules over a (non) PID
QUESTION [5 upvotes]: I am looking for an example of a commutative ring with $1$, in which every ideal is generated by a single element, for which the conclusion of the structure theorem for finitely generated modules is wrong. (The ring is allowed to have zero divisors, so it is not a PID).
Are there any examples? What happens if one drops the other conditions instead (commutativity, $1\in R$)? Does then the structure theorem still fail ?

REPLY [3 votes]: The note linked to in Timothy Wagner's answer has been replaced by another one, which only shows the structure theorem for PIDs, so it may be worth to point out that the structure theorem holds for any principal ideal ring (PIR), possibly with zero divisors. Namely, a theorem of Zariski-Samuel tells us that a PIR is a direct product of PIDs and local artinian PIRs. For these, the structure theorem holds and one has uniqueness (for the latter, see Keenan Kidwell's question he mentioned in the comment). Since a module $V$ over a ring $R= R_1 \times \dotsb \times R_n$ decomposes canonically as $V= Ve_1\oplus \dots Ve_n$, where the $e_i$ are the obvious idempotents, and $Ve_i$ is an $R_i$-module, we are done.