Pau Lo
asked on
query tools
what tools on windows server (with oracle installed) do you typically use to run SQL queries against a database? And what do you refer to the query tools/software as? And if you have a huge batch of seperate SELECT type queries, that you want to run in one swoop, as opposed to one after the other, how do you go about this in oracle query tools? Can you add a number of queries into a script to run all at once, or how would you approach this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For non-interactive tasks dbms_scheduler, sqlplus and PowerShell are the way to go IMHO. PS works great if you need more advanced formatting, but HTML (which I would prefer here) can be generated by PS and sqlplus. PS has the additional advantage that sending results as mail is a piece of cake.
ASKER
can you give a bit of a beginners guide to running multiple queries in one go using sqlplus.
also is sqlplus something you get and install on oracle db servers with linux/unix type OS.
also is sqlplus something you get and install on oracle db servers with linux/unix type OS.
SQL*Plus is included in both server and client software installations, independent from OS.
With a SQL batch for reporting, the issue isn't usually to run more than one SQL statement, but to do so with proper formatting, as you usually create different tables with different layout.
There are several ways to active HTML reporting in sqlplus (which I recommend to use). You can either tell the sqlplus call on commandline to generate HTML, and to store into a file, or do that inside of the script. I'll show the "all-in-one script" way:
With a SQL batch for reporting, the issue isn't usually to run more than one SQL statement, but to do so with proper formatting, as you usually create different tables with different layout.
There are several ways to active HTML reporting in sqlplus (which I recommend to use). You can either tell the sqlplus call on commandline to generate HTML, and to store into a file, or do that inside of the script. I'll show the "all-in-one script" way:
set MARKUP HTML ON SPOOL on
spool 'report.html'
select a, b, c from tbl1;
select e, f from tbl2;
-- and so on
spool off
Name that report.sql and call it withsqplus usr/pwd@tns -silent -restrict @report.sql
ASKER
so all results will end up in a single html report? how would you diffrentiate between the results/output, i.e. which rows are from which query, .....or is it one html report per query?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I expected you to want a single file containing all reports, and the results being obvious. Just try if the result file meets your needs.
If you want to have different files for each table, just insert a
If you want to have different files for each table, just insert a
spool off
spool 'DifferentFile.html'
with a changing file name, of course, between each SQL statement.
A supplement to Qlemo's prior post, SPOOL cannot be nested.
ASKER