Question: how to export data to csv from oracle database using pl sql script?
Answer: Create a Directory Object in which you will write CSV file. ... 
Create a Database Procedure in Scott schema or if you are creating in another schema then make sure you have the Emp table in that schema, else you need to change the Cursor and the field references for any other table. ... 
Now run the procedure as follows: