0

I am having trouble creating a .sql batch file that can execute a select statement on SQL Developer.

This is my code:

set pagesize 500
spool  @c:\temp\output.log
set echo on 

SELECT OBJECT_NAME 
FROM DBA_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'
AND OWNER = 'DWBATCH'
GROUP BY = 'OBJECT_NAME'

spool off

The script will display the original output, and the select statement is not being executed. I will appreciate any input to what is wrong with this script, since it should work according to my knowledge.

VJAS
  • 1
  • 4
  • You need a semicolon at the end of your query. (Or a slash on the next line). [See the documentation](http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_four.htm#sthref273). Your group-by is wrong too though, so are you getting an ORA-00936 error? – Alex Poole Jan 09 '17 at 19:08
  • The group by was not needed so I edited that out and added in a semi-colon at the end. I am not getting a error instead It is displaying the original output, which would be displayed without the select statement. – VJAS Jan 09 '17 at 19:49
  • Not sure what you mean about original output. If you're running this as a script (F5) clear the script output window, run it again, and copy what is in the output window as text - and add it to the question. Maybe you just mean you're seeing the command echoed, which is normal; [this may be usefui](http://stackoverflow.com/a/19034156/266304). But you should see the query results too (even if it just says 'no data found'). – Alex Poole Jan 09 '17 at 19:52
  • This is not related to tag [tag:batch-file] (read the [tag info](http://stackoverflow.com/tags/batch-file/info))! – aschipfl Jan 10 '17 at 12:38
  • You are missing a `;` at the end of your SQL statement. –  Jan 10 '17 at 12:56

0 Answers0