"a" is the index variable in a for loop and should not get manually incremented. If left alone it will increment itself. You don't state the error message, but without running the code I'm guessing that that is it. You are also seemingly trying to print out the same query 10 times without changing it. What are you really trying to do, and what error are you getting?
for a in 1 .. 10 loop
i := 'select count(*) from messages';
a := a + 1;