Remove Column Header into the Output Text file - oracle

I want to create a flat file (text file) of my query from Oracle SQL Developer.
I have successfully created the text file using SPOOL, thru a script text file, but i want to remove the header of each column into my output.
I am getting this output:
Header000001 Header000002
------------ ------------
Adetail1 Bdetail1
Adetail2 Bdetail2
Adetail3 Bdetail3
But, I want to get this output:
Adetail1Bdetail1
Adetail2Bdetail2
Adetail3Bdetail3
I already tried the command "set heading off", but a message says:
"SQLPLUS COMMAND Skipped: set heading off".
These are the inputs I've issued:
spool on;
spool C:\SQLFiles\PSB_ATMLKP.txt;
set newpage 0;
set echo off;
set feedback off;
set heading off;
select terminal_number, terminal_name from terminal_table;
spool off;

SQLPLUS COMMAND Skipped: set heading off
That message is most likely because you are not executing it through SQL*Plus, but some GUI based tool. You are using SQLPlus command in SQL Developer. Not all SQL*Plus commands are guaranteed to work with SQL Developer.
I would suggest you execute the script in SQLPlus and you would see no issues.
You need:
SET HEADING OFF
This will not include the column headers in the output.
Alternatively, you could also do this:
SET PAGESIZE 0
Using SQL Developer Version 3.2.20.10:
spool ON
spool D:\test.txt
SET heading OFF
SELECT ename FROM emp;
spool off
Spool file got created with no issues:
> set heading OFF
> SELECT ename FROM emp
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
14 rows selected

Add:
set underline off
to the beginning of the SQL script.
In my SQL scripts I have:
SET TERMOUT OFF
set colsep |
set pagesize 0
set trimspool on
set pagesize 0 embedded on
SET heading on
SET UNDERLINE OFF
spool file_path
-- your SQL here
spool off
See this book for reference.

Related

Heavy file generated on spooling in unix

I run this code from a unix file.
Please Find Below my code
set colsep ,
set heading off
set pagesize 0
set feedback off
set linesize 32767
set trimspool on
set tab off
spool My_File
select * from my_table; /* it has 45 records*/
spool off;
Once I run this code, I have my output file generated, but the columns are seperated with very big spaces and even the records are seperated with big spaces. As a result I get a very huge file.
Is there any workaround for this ... Thanks in advance..
What i do in these situations is not to use colsep and and do the concatenation myself.
set heading off
set pagesize 0
set feedback off
set linesize 32767
set trimspool on
set tab off
spool My_File
select column1||','||column2||','||column3.... from my_table;
spool off;

How to export half a million records from PL/SQL

I've a table with around 500,000 records. I need all records to be exported in excel. When I query I'm not able to get all as I was said as Out Of memory
Table doesn't have any primary key/Index.
Is there any way to extract?
it would be very easy in to write file output form sqlplus .
mycsv.sql:
SET DEFINE OFF
SET ECHO OFF
SET SERVEROUTPUT OFF
SET TERMOUT OFF
SET VERIFY OFF
SET FEEDBACK OFF
SET PAGESIZE 10000
SET ARRAYSIZE 5000
REM SET HEAD OFF
SET LINE 500
spool /tmp/mycsvfile.csv;
select * from MY_table;
spool off;
exit;
and from Linux prompt you can run like
$> sqlplus username/password #/tmp/mycsv.sql

Prevent Spool to add SQL query in output file

I want my script to stop printing the SQL query in the output file.
I have tried different method, but its just not happening.
sqlplus user/password#(TNS Entry) << EOF
SET head OFF;
SET feed OFF;
SET trimspool ON;
SET linesize 32767;
SET pagesize 32767;
SET echo OFF;
SET termout OFF;
SET verify OFF;
SET NEWPAGE NONE;
SET verify off;
#test.txt
spool file_name.csv
select * from Customer;
spool off
EXIT;
EOF
Could you help please , I want csv file to have just the result of the SQL query and nothing else.
Put your commands in a file. Then run that from SQLPUS.
So for instance make a file query.sql.
SQL>#query.sql
Now SQL won't put the query in the spoolfile.
This way SQLPLUS will listen to your set .. off commands. See the documentation.
*SET ECHO {ON | OFF}
Controls whether or not to echo commands in a script that is executed
with #, ## or START. ON displays the commands on screen. OFF
suppresses the display. ECHO does not affect the display of commands
you enter interactively or redirect to SQLPlus from the operating
system.**

blanks lines in between data rows show up when using SPOOL in SQLPlus

I'm trying to spool a large query in sqlplus but for some reason, I see 2 blank lines every 558 rows to be exact.
I spool as such:
SET TERMOUT OFF
SET ECHO OFF
SET LINES 1000
SET FEEDBACK off
SET HEADING OFF
SET ARRAYSIZE 10000
SET NEWPAGE NONE
SET PAGESIZE 0
SET TRIMSPOOL ON
Spool D:\IPORT15.csv
select query
Spool OFF;
EXIT
I thought SET NEWPAGE was supposed to take care of that??
I was able to resolve this by setting: "SET PAGES 0"

Oracle 11g Report Problem

Hey friends i am using Oracle 11G. I wanted to generate reports for printing , SO i write this script
rem Employee Salary Report
set headsep !
ttitle 'Salary Report'
btitle 'From Employees'
column employee_id format 999.99
column first_name format a20
column last_name format a20
column Salary format 999.99
break on employee_id skip 1 on report
set linesize 80
set pagesize 5
set newpage 0
set feedback off
set pause 'More...'
set pause on
spool activity.lst
select employee_id,first_name,last_name,salary from Employees order by employee_id ;
spool off
When running this script oracle gives
line 3: SQLPLUS Command Skipped: set headsep !
line 15: SQLPLUS Command Skipped: set linesize 80
line 16: SQLPLUS Command Skipped: set pagesize 5
line 17: SQLPLUS Command Skipped: set newpage 0
and then it executes query and gives output. But my report doesn't include any title in it.Means reports is not generated properly. It just simply executes the select query and gives an output which is not a report.
Did you have a question?
What you show us looks very much like the output we would expect if your script was run from the SQL Worksheet in Oracle SQL Developer.
Those commands that are being skipped are specific to SQL*Plus, and are not supported in SQL Developer (at least, in the version I'm running).
To get a formatted report produced by SQL*Plus, I would run the sqlplus executable from the OS e.g.
> $ORACLE_HOME/bin/sqlplus /
SQL> #/home/spencer7593/myreport.sql
SQL> exit
>
I'm not sure that answers a question, since I don't know what your question was.

Resources