How to execute sql file in Oracle

Greeting,

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

Pls suggest.

Thanks.
mrongAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexander Eßer [Alex140181]Software DeveloperCommented:
in sqlplus:

SQL> spool output.txt
SQL> @select.sql

Open in new window


you could put the spool command into the script and only exec the .sql file, that would be up to you...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
YZlatCommented:
don't forget to run

SQL>spool off

at the ened
0
awking00Information Technology SpecialistCommented:
SQL> spool C:\output.txt
SQL> @select.sql
SQL> spool off;  => just need to add this (no points, please)
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

awking00Information Technology SpecialistCommented:
Sorry, YZlat, didn't see your post before I submitted.
0
mrongAuthor Commented:
where should I put select.sql?
thanks.
0
mrongAuthor Commented:
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.
Thanks.
0
Alexander Eßer [Alex140181]Software DeveloperCommented:
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)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.