Toby
Toby

Reputation: 145

Creating a text file from PL/SQL Developer

Can someone explain how to create a text file and save to my C drive from a select query? Anytime I run the query I would like the query to replace the old text file with the new query data.

Upvotes: 0

Views: 4128

Answers (1)

Prashant Mishra
Prashant Mishra

Reputation: 647

You will need to follow the steps :

  1. save this in file named get_data.sql

    SET HEADING OFF
    SET FEEDBACK OFF
    SET TERM OFF
    SET LONG 100000
    SPOOL Dept_100.txt
    select 'EmployeeName  : '||Emp_id from Employee where Deptno = 100;
    SPOOL OFF
    
  2. on CMD, Go to the folder where the script is.

  3. connect using sqlplus through command prompt.

  4. Run the script

    SQL>@spool.sql
    
  5. spool.sql contains select statement which will select employeename of all employees who work for Dept :100(Just for example).

  6. running spool.sql will create a file "Dept_100.txt" containing employeenames.

Upvotes: 0

Related Questions