I am using Oracle SQL Developer 2.1.1.64 to spool the results of a query to a text file Here is what I am running to call the quesry and spool the results
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET FEEDBACK OFF
SET HEADING OFF
set verify off
SET ECHO OFF
spool c:\client\output_sql\t_1001_02_0522_.txt
@c:\client\queries\t_1001_02_query;
spool off
Unfortunately, i am getting
@c:\client\queries\t_1001_02_query
at the top of my output text file and I need to have just the results. I have searched the web for this and have tried a variety of things like: set verify off set termout off
This question is related to
oracle
oracle-sqldeveloper
I have found that if I save my query(spool_script_file.sql) and call it using this
@c:\client\queries\spool_script_file.sql as script(F5)
My output now is just the results with out the commands at the top.
I found this solution on the oracle forums.
You can export the query results to a text file (or insert statements, or even pdf) by right-clicking on Query Result row (any row) and choose Export
using Sql Developer 3.0
See SQL Developer downloads for latest versions
For Spooling in Oracle SQL Developer, here is the solution.
set heading on
set linesize 1500
set colsep '|'
set numformat 99999999999999999999
set pagesize 25000
spool E:\abc.txt
@E:\abc.sql;
spool off
The hint is :
when we spool from sql plus , then the whole query is required.
when we spool from Oracle Sql Developer , then the reference path of the query required as given in the specified example.
Another way simpler than me has worked with SQL Developer 4 in Windows 7
spool "path_to_file\\filename.txt"
query to execute
spool of
You have to execute it as a script, because if not only the query will be saved in the output file In the path name I use the double character "\" as a separator when working with Windows and SQL, The output file will display the query and the result.
I was trying things to duplicate the spools you get from sqlplus. I found the following and hope it helps:
Create your sql script file ie:
Please note the echo and serveroutput.
Test_Spool.SQL
Spool 'c:\temp\Test1.txt';
set echo on;
set serveroutput on;
declare
sqlresult varchar2(60);
begin
select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') into sqlresult from dual;
dbms_output.put_line('The date is ' || sqlresult);
end;
/
Spool off;
set serveroutput off;
set echo off;
Run the script from another worksheet:
@TEST_Spool.SQL
My output from the Test1.txt
set serveroutput on
declare
sqlresult varchar2(60);
begin
select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') into sqlresult from dual;
dbms_output.put_line('The date is ' || sqlresult);
end;
anonymous block completed
The date is 2016-04-07 09:21:32
Spool of
Source: Stackoverflow.com