under which account do you run your program ?
is the table SPACES accessible from the account you use ?
do you have the right to ANALYZE this table ???