Home > Mobile >  Using spool in Oracle 11g doesn't send the result of SELECT queries to the file
Using spool in Oracle 11g doesn't send the result of SELECT queries to the file

Time:05-21

I am executing the following query for an assignment where I need to output the content of some tables to a file using SPOOL. When I run it, only the statements are written to the file and not the results. I've searched Stack Overflow and the Oracle Database to find out why and got nowhere.

Other people with the same assignment aren't getting this problem. The server is inside a VM that is given to us for the assignment so they are all setup the same.

Am I missing something obvious? When SPOOL was showcased on this environment it worked properly. Also, just a side note, I cannot use the APPEND keyword with SPOOL because it will either give me an error message that the file can't be created or the file will be named: 'content.lst APPEND'. I tried no quotes, single quotes and double quotes.

Here is the content of my SQL file:

SPOOL "C:\content.lst";
SELECT * FROM client;
SELECT * FROM produit;
SELECT * FROM employe;
SELECT * FROM vente;
SELECT * FROM vente_produit;
SPOOL OFF;

The output inside the content.lst file is:

SPOOL "C:\content.lst";
SELECT * FROM client;
SELECT * FROM produit;
SELECT * FROM employe;
SELECT * FROM vente;
SELECT * FROM vente_produit;
SPOOL OFF;

How do I get the result of the SELECT statements to show up in the file? They do return data, SQL Developer open tabs of the results and the data is good.

Thank you for pointing me in the right direction.

CodePudding user response:

Please make sure you run your statements as a script (using the Run Script F5) button and not as a regular command execution.

  • Related