Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle SQL Developer spool output?

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

like image 447
mooseman Avatar asked May 23 '13 19:05

mooseman


People also ask

How do I spool in Oracle?

Enter SPOOL with no clauses to list the current spooling status. To spool output generated by commands in a script without displaying the output on the screen, use SET TERMOUT OFF. SET TERMOUT OFF does not affect output from commands that run interactively.

How do I display output in SQL?

To do this we use a procedure called dbms_output. put_line to place the results in a buffer that SQL*Plus will retrieve and display. SQL*Plus must be told to retrieve data from this buffer in order to display the results. The SQL*Plus command 'set serveroutput on' causes SQL*Plus to retrieve and display the buffer.


2 Answers

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.

like image 156
mooseman Avatar answered Oct 05 '22 01:10

mooseman


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 :

  1. when we spool from sql plus , then the whole query is required.

  2. when we spool from Oracle Sql Developer , then the reference path of the query required as given in the specified example.

like image 38
Pvz Avatar answered Oct 05 '22 01:10

Pvz