4

Dears, I cannot use spool command. It is not working or i am not doing something right. I am trying to save query result in txt file (tried also csv saving with select /*csv*/ * from table but it also did not work).

So what i wrote is:

set echo off
set trimspool on
spool 'C:\Users\username\Desktop\clobams\Test1.txt'
select  pn, serial_number from stock ;
spool off;

And i am getting error when pressing execute statement ORA-00900:invalid SQL statement . Sql works fine - when i execute only that part,it gives me output to the screen. How should i save my output to the file?

I have already tried to remove set echo off and set trimspool on but none of these helped

6
  • Why have you wrapped the file path in single quotes? Try removing them. Commented Mar 28, 2018 at 7:53
  • Just tried. Got same error: invalid SQL statement. Commented Mar 28, 2018 at 8:02
  • Click on the button next to execute ( Run script ) or simply press F5 Commented Mar 28, 2018 at 8:48
  • Dear Kaushik, it works now! It was a complex problem: firstly - no need of single quotes, secondly it was Run Script, which worked. Commented Mar 28, 2018 at 9:16
  • Do you know how it will be possible to extend saved result size? It has clob in it and now it trims to 4000 chars. Commented Mar 28, 2018 at 9:17

1 Answer 1

3

this is what i have run on my sql developer:

spool C:\Users\**direcotory**\Desktop\old desktop\sql\Test1.txt;
select  *  from YOUR_TABLE;
spool off;

and i got output in file test1. you need to run all commands as script.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.