::
=========================================================================================
:: SelfRunner.bat Real-time Oracle-Htm
Report
::
=========================================================================================
:: Generate and run a self-running sql-htm page
from a windows batch file.
:: 1.Tabbed Browsing: Tested on IE. Please turn
off tabbed browsing to refresh on same page.
:: 2.Activex Control: Please choose yes to allow
blocked content message when IE opens.
::
Works fine with default IE activex
security setting.
::
Annoyance: Extra click to allow activex
control that runs the script.
:: 3.Command Window : Position the Command Window
away from the top left of the page.
::
Start-Run-Cmd-RightClickOnTitleBar-Properties-WindowPosition-
::
Left-750;Top-350-PressOkay-Choose
SavePositionForFutureWindows...
:: 4.Meta Character Mess-up : Meta characters in
echo statements that need to be escaped by
::
a ^ are, acc
to docs, in this list [ & && | || ( ) < > <<
>> ].
::
========================================================================================
:: Jerome Christopher.
[Jerome_christopher@yahoo.com]
:: http://htmsql.blogspot.com/
:: http://www.sqlhtm.com/sqlhtm/selfrunner
::
========================================================================================
(
echo set pages 200
echo set lines 180
echo set feedback off
echo set termout off
echo set HEADING OFF
echo
--------------------------------------------------------------------------------------
echo alter session set
nls^_date^_format^='dd-mon-yyyy hh24:mi:ss';
echo SELECT ^'^<^'^|^|^'style
type^=^'^|^|^'^'^'^'^|^|^'text^'^|^|^'^/^'^|^|^'css^'^|^|^'^'^'^'^|^|^'^>^'^|^|
chr^(10^)^|^|chr^(13^)^|^|
echo ^'body {font:7pt
Arial^,Helvetica^,sans^-serif; color:black;
background:#535300;padding:0px 0px 0px
0px;background-image:url^(^"^"^)}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'p {font:bold 8pt
Arial^,Helvetica,sans^-serif; color:red;
background:lightaqua;padding:0px 0px 0px 0px; margin:0px 0px 0px
0px;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'table {font:7pt
Arial^,Helvetica^,sans-serif; color:Black; background:green;
padding:0px 0px 0px 0px; margin:0px 0px 0px
0px;vertical^-align:top}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'tr {font:7pt
Arial^,Helvetica^,sans-serif; color:Black; background:; padding:0px
0px 0px 0px; margin:0px 0px 0px
0px;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'td {font:bold 8pt
Arial^,Helvetica^,sans-serif; color:black; background:cyan;
padding:0px 0px 0px 0px; margin:0px 0px 0px
0px;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'th {font:bold 6pt
Arial^,Helvetica^,sans-serif; color:yellow; background:darkgreen;
padding:0px 0px 0px 0px;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'h1 {font:bold 15pt
Arial^,Helvetica^,Geneva^,sans-serif; color:black;
background:silver; }^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'h2 {font:bold 9pt
Arial^,Helvetica^,Geneva^,sans-serif; color:black;
background:magneta; margin^-top:0px;
margin^-bottom:0px;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'a {font:bold 8pt
Arial^,Helvetica^,sans-serif; color:black;
background:darkkhaki;padding:0px 0px 0px 0px; margin^-top:0pt;
margin^-bottom:0pt;
vertical^-align:top;}^'^|^|chr^(10^)^|^|chr^(13^)^|^|
echo ^'^<^'^|^|^'^/^'^|^|^'style^>^' FROM
dual;
echo
--------------------------------------------------------------------------------------
echo SET MARKUP HTML ON TABLE ^"^" ENTMAP OFF
echo SET HEADING ON
)>c:\srss.out
::
======================================================================================
@echo off
del c:\sr1.tmp c:\sr2.tmp c:\sr3.tmp
echo spool c:^\SelfRunner.htm
>c:\sr1.tmp
echo set termout off
>>c:\sr1.tmp
echo prompt ^<html^>^<head^>
>>c:\sr1.tmp
echo prompt ^<script
type^=^"text^/javascript^"^>
>>c:\sr1.tmp
echo prompt function runApp^(which^)
>>c:\sr1.tmp
echo prompt { WshShell ^= new
ActiveXObject^(^"WScript.Shell^"^);
>>c:\sr1.tmp
echo prompt WshShell.Run
^(which^,1^,false^);
>>c:\sr1.tmp
echo prompt var win ^=
window.open^(^"c:^/SelfRunner.htm^"^,^"^_self^"^)>>c:\sr1.tmp
echo prompt if ^(win^) win.onload ^=
runApp
>>c:\sr1.tmp
echo prompt }
>>c:\sr1.tmp
echo prompt ^<^/script^>
>>c:\sr1.tmp
::
======================================================================================
type c:\srss.out
>c:\sr2.tmp
copy c:\sr1.tmp+c:\sr2.tmp c:\sr3.tmp
>NUL
::
======================================================================================
echo prompt ^<^/head^>
>>c:\sr3.tmp
echo prompt ^<body^>
>>c:\sr3.tmp
echo prompt ^<table border^=5
title^=SelfRunner-Real-TimeOracleDataRefresh ^>
^<tr^>^<td valign^=^"top^"^> >>c:\sr3.tmp
echo select name
DbName^,to^_char^(sysdate^,^'dd^-mon^-yy hh:mi:ss pm Dy^'^) Today
from v^$database; >>c:\sr3.tmp
echo prompt ^<INPUT TYPE^=button
VALUE^=^"SelfRunner - Press To Refresh - See The Values Change In
Real Time !!!^" TITLE^=^"ClickHere^" STYLE^=^"color:yellow;
background^-color:darkgreen^"
onClick^=^"runApp^(^'file:^/^/c:^/SelfRunner.bat^'^)^"^>
>>c:\sr3.tmp
rem echo prompt ^<^/td^>^<td
valign^=^"top^"^>
>>c:\sr3.tmp
echo prompt
^<^/td^>^<^/tr^>^<tr^>^<td valign^=^"top^"^>
>>c:\sr3.tmp
echo prompt ^<a^>1.Some sysstat parameters
to watch:^<^/a^>
>>c:\sr3.tmp
echo select * from v$sysstat where
value^>0 and name in
>>c:\sr3.tmp
echo ^(
>>c:\sr3.tmp
echo 'recursive calls'
>>c:\sr3.tmp
echo ,'recursive cpu usage'
>>c:\sr3.tmp
echo ,'DB time'
>>c:\sr3.tmp
:: echo ,'cluster wait time'
>>c:\sr3.tmp
:: echo ,'sorts ^(rows^)'
>>c:\sr3.tmp
echo ,'sorts ^(memory^)'
>>c:\sr3.tmp
echo ,'sorts ^(disk^)'
>>c:\sr3.tmp
echo ,'physical reads'
>>c:\sr3.tmp
echo ,'redo size'
>>c:\sr3.tmp
echo ,'redo wastage'
>>c:\sr3.tmp
echo ,'table scans ^(short tables^)'
>>c:\sr3.tmp
echo ,'table scans ^(long tables^)'
>>c:\sr3.tmp
echo ,'table fetch continued row'
>>c:\sr3.tmp
echo ,'user I^/O wait time'
>>c:\sr3.tmp
echo ^)
>>c:\sr3.tmp
echo order by name ;
>>c:\sr3.tmp
rem echo prompt
^<^/td^>^<table^>^<tr^>^<td
valign^=^"top^"^>
>>c:\sr3.tmp
echo prompt ^<^/td^><td
valign^=^"top^"^>
>>c:\sr3.tmp
echo prompt ^<a^>2.Top 4 users - ordered by
seconds_in_wait:^<^/a^>
>>c:\sr3.tmp
echo select * from ^(select
sid,serial#,username,status,program,type,user,module,logon^_time,wait^_time,seconds^_in^_wait
from v$session where type^<^>'BACKGROUND' order by
seconds^_in^_wait desc^) where rownum^<5;
>>c:\sr3.tmp
echo prompt ^<^/td^><td
valign^=^"top^"^>
>>c:\sr3.tmp
echo prompt ^<a^>3.Top 4 Filestat info -
ordered by physical reads:^<^/a^>
>>c:\sr3.tmp
echo select * from ^(select * from v$filestat
order by phyrds desc ^) where rownum ^< 5;
>>c:\sr3.tmp
rem echo prompt
^<^/td^>^<^/tr^>^<^/table^>^<hr^>
>>c:\sr3.tmp
echo prompt ^<^/td^><td
valign^=^"top^"^>
>>c:\sr3.tmp
echo prompt ^<a^>4.Top 4 waits from
system_event - ordered by time_waited: ^<^/a^>
>>c:\sr3.tmp
echo select * from ^(select * from
v$system_event order by time_waited desc^) where rownum ^<
5; >>c:\sr3.tmp
echo prompt
^<^/td^>^<^/tr^>^<^/table^>
>>c:\sr3.tmp
echo spool off
>>c:\sr3.tmp
echo exit
>>c:\sr3.tmp
sqlplus -s "dbuser/password@db" "@c:\sr3.tmp"
>>c:\sr3.tmp
echo ^<^/body^>^<^/html^>
>>c:\SelfRunner.htm
::
======================================================================================
start "C:\Program Files\Internet
Explorer\iexplore.exe" c:\SelfRunner.htm
exit