SQL developer spool not working when calling the sql file

Viewed 29

Note: I have configured the tools-preferences-worksheet-select default path to a predefined one in which all my scripts are stored.

I have a sql script myscript1.sql with the below code. If I open it in SQL developer, select all and run the script (F5), it successfully fills mytab.csv with data if that file exists previously.

SPOOL "mytab.csv";

SELECT /*csv*/
    do_not_recall,
    campaign_code,
    INPUTFROM
FROM
    dal_brut
WHERE
    ROWNUM < 10;

SPOOL off;

Output (it produces data in the file as well): "DO_NOT_RECALL","CAMPAIGN_CODE","INPUTFROM"

"","Live","BAU"
"","Final","BAU"
"","Final","BAU"
"","Live","BAU"
"","Final","BAU"
"","Live","BAU"
"","Final","BAU"
"","Live","BAU"
"","Live","BAU"

9 rows selected. 

However, if I call myscript1.sql from a new worksheet like this:

@myscript1.sql

Output (it does not insert any data in mytab.csv):

"DO_NOT_RECALL","CAMPAIGN_CODE","INPUTFROM"
"","Live","BAU"
"","Final","BAU"
"","Final","BAU"
"","Live","BAU"
"","Final","BAU"
"","Live","BAU"
"","Final","BAU"
"","Live","BAU"
"","Live","BAU"

9 rows selected. 

How can I get the 2nd chunk of code to insert data as well to mytab.csv?

0 Answers
Related