Maybe. You don't show an insert query in the excerpt above, but error message regarding "Duplicate entry" is the result of an SQL insert statement.
Your database has a PRIMARY KEY set on whatever field you're trying to put the string "LL2001-001" into. This is to make sure that the column (which is probably named something like ID, or "ordinal", or something) contains only unique values.
It kind of looks like the next ID should be "LL2001-002" ... so if you can construct that number, and use it for the next iteration of the loop?