Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLCL Batch Scripting : Auto Connection + EXPORT CSV

SQLCL is exactly what I need, but I've a big difficulty on one little thing :

I want to make a script (batch file) with Auto connection and just after an EXPORT CSV (on a remote desktop : not on the server).

So I'm using the pipe method with SQLCL in a Batch File:

echo SET SQLFORMAT CSV <
echo SPOOL export.csv <
echo SELECT COUNT(*) FROM ARTICLE; <
echo SPOOL OFF | C:\Work\Soft\sqlcl\bin\sql.exe login/[email protected]:1521/DB.SCH

It's working (no errors in console) but, impossible to find the file export.csv : when I change the destination c:\... it's working too but impossible to find the created file. It's working fine with SQL Developer and the file is created on my dekstop, so I don't understand why it's not the same case for SQLCL.

like image 343
Quentin T. Avatar asked Oct 31 '17 14:10

Quentin T.


People also ask

What feature does SQL developer have in common with SQLcl?

Oracle SQLcl (SQL Developer Command Line) is a Java-based command-line interface for Oracle Database. Using SQLcl, you can interactively or batch execute SQL and PL/SQL statements. SQLcl provides inline editing, statement completion, command recall, and also supports existing SQL*Plus scripts.


1 Answers

I had the answer from the oracle Platform :

@echo off  
echo SET SQLFORMAT CSV ^& ^  
echo SET FEEDBACK OFF ^& ^  
echo SPOOL export.csv ^& ^  
echo SELECT COUNT^(*^) FROM dual ^& ^  
echo SPOOL OFF |  C:\Work\Soft\sqlcl\bin\sql.exe sql -noupdates -s -l login/[email protected]:1521/DB.SCH

Thank to Gaz in Oz

like image 105
Quentin T. Avatar answered Nov 15 '22 07:11

Quentin T.