I am trying to spool results directly to a CSV using a few substitution variables. I have this query:
SET echo off
set feedback off
set pagesize 0
set termout off
define vpath=C:\14-0724_Spool testing\'
SELECT /*csv*/ table1.SOURCE_DMS_ID,
table1.DATE BETWEEN to_date('&&startdate') and to_date('&&enddate')
--AND table1_DATE BETWEEN '01-JAN-14' and '31-JAN-14'
GROUP BY table1_DIM.SOURCE_DMS_ID;
Assuming SQL_Developer is sqlplus compliant, first, try adding "SET VERIFY OFF" . If that doesn't work you can also try putting the spool after the query as in the following example:
set verify off define x = 'X' select * from dual where '&x' = 'X' spool x.out / spool off
Note the blank line after the SELECT, and the absence of the semi-colon after the SELECT statement.