SQL Plus - Export CSV without Query in File

Asked

Viewed 76 times

0

I am trying to export the result of a query in SQL PLUS to a CSV. It is working, but I want used for extraction is coming in the first lines of the CSV file, which hinders the end user. Have some command I have to add so that the query does not come together, only the result?

The command used for export:

sqlplus login/senha << EOF

set echo on 
set define on
set feedback off
set serveroutput on
set arraysize 500
set verify off
set pagesize 0
set linesize 10000
ser trimspool on
set termout off

alter session set nls_date_format = 'dd/mm/yyyy hh24:mi:ss';

spool /CAMINHO_ABSOLUTO/nome_do_arquivo.csv;

SELECT * FROM EXEMPLO;
  • I solved the problem using a command line extractor.

1 answer

0

This is a consequence of how the commands are being processed by Sqlplus.

The parameter SET ECHO OFF (see description below taken from documentation) allows this but because they are redirecting the text into Sqlplus the parameter is ignored.

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 SQL*Plus from the operating system.

If the content of the EOF block is placed in an isolated file and the invocation becomes:

sqlplus login/senha @sql_script

Searches no longer appear in the file referred to in the command SPOOL.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.