Domanda

I am trying to export an Oracle SQL+ query as a txt file. So far everything works, BUT I need to get the heading to show in my query. For whatever reason, even with Set Heading On checked, it still doesnt work. Where am I going wrong?

column Fruit Format a15;
column Quantity Format a15;
SET LINES 32000
SET TERMOUT OFF ECHO OFF NEWP 0 SPA 0 PAGES 0 FEED OFF TRIMS ON TAB OFF ECHO OFF    PAGESIZE 0
SET HEADING ON

select
fruit as Fruit,
number as Quantity
from fruit_table;
spool test.txt
spool off
È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top