Avatar of mrong
mrong asked on

How to execute sql file in Oracle


I need to execute select.sql from Oracle SQL plus worksheet and put output into C:\output.txt.

Pls suggest.

Oracle DatabaseSQL

Avatar of undefined
Last Comment
Alex [***Alex140181***]

8/22/2022 - Mon
Alex [***Alex140181***]

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

don't forget to run

SQL>spool off

at the ened

SQL> spool C:\output.txt
SQL> @select.sql
SQL> spool off;  => just need to add this (no points, please)

Sorry, YZlat, didn't see your post before I submitted.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

where should I put select.sql?

Is there anyway to show the sql stmt in the output file? now it only show the output and I won't be able to tell which for which.
Alex [***Alex140181***]

where should I put select.sql?
That is up to you/your app ;-)

Is there anyway to show the sql stmt in the output file?
Try "set echo on" and/or "set serveroutput on" (in sqlplus) before executing your .sql file
(or put it right at the beginning of your select.sql)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.