The problem is this part of your SET
statement:
PAGES 0 ... PAGESIZE 0
In SQL*Plus, pagesize
(or pages
, the one is short for the other) means "after how many lines do you want the heading to repeat?" The default is 20, so we get the heading repeated every twenty rows.
It's counter-intuitive, but setting pagesize
to 0 has the effect of suppressing the headings, regardless of the value of heading
.
Incidentally, you need to put the SELECT command between the spool ...
and spool off
. Otherwise you'll end up with an empty file.