<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>remidian.com</title>
	<atom:link href="http://remidian.com/feed" rel="self" type="application/rss+xml" />
	<link>http://remidian.com</link>
	<description>Braindumps of Remi Visser, freelance Oracle DBA.</description>
	<lastBuildDate>Mon, 10 May 2010 12:33:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Purging SYSAUX tablespace (Purging AWR reports)</title>
		<link>http://remidian.com/oracle/purging-sysaux-tablespace-purging-awr-reports.html</link>
		<comments>http://remidian.com/oracle/purging-sysaux-tablespace-purging-awr-reports.html#comments</comments>
		<pubDate>Tue, 18 Aug 2009 10:52:10 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[Grid]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://remidian.com/?p=265</guid>
		<description><![CDATA[Dump below is of a session clearing the sysaux tablespace. It turned out that something went wrong with the automatic AWR gathering/purging and the sysaux tablespace became very large. Thanks to this blog I found script below wich displays the various sysaux components and their sizes. SQL&#62; col &#34;Space (M)&#34; for 999,999.99&#160;&#160; SQL&#62; SQL&#62; SELECT [...]]]></description>
			<content:encoded><![CDATA[<p>
Dump below is of a session clearing the sysaux tablespace. <span id="more-265"></span>It turned out that something went wrong with the automatic AWR gathering/purging and the sysaux tablespace became very large.
</p>
<p>
Thanks to <a href="http://jhdba.wordpress.com/2009/05/19/purging-statistics-from-the-sysaux-tablespace/">this blog</a> I found script below wich displays the various sysaux components and their sizes.
</p>
<pre>
SQL&gt; col &quot;Space (M)&quot; for 999,999.99&nbsp;&nbsp;
SQL&gt; 
SQL&gt; SELECT 
&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;occupant_name,&nbsp;&nbsp;
&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;round( space_usage_kbytes/1024) &quot;Space (M)&quot;,&nbsp;&nbsp;
&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;schema_name, 
&nbsp;&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;move_procedure
&nbsp;&nbsp;6&nbsp;&nbsp;FROM 
&nbsp;&nbsp;7&nbsp;&nbsp;&nbsp;&nbsp;v$sysaux_occupants&nbsp;&nbsp;
&nbsp;&nbsp;8&nbsp;&nbsp;ORDER BY 
&nbsp;&nbsp;9&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;
 10&nbsp;&nbsp;/
OCCUPANT_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Space (M) SCHEMA_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MOVE_PROCEDURE
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
AO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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;&nbsp;&nbsp;&nbsp;DBMS_AMD.Move_OLAP_Catalog
XSOQHIST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.00 SYS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBMS_XSOQ.OlapiMoveProc
&nbsp;
22 rows selected.
&nbsp;
SQL&gt;&nbsp;&nbsp; 
SQL&gt; 
</pre>
<p>
Next thing I retrieve the oldest and latest AWR snapshot, turns out to be 2007&#8230;
</p>
<pre>
SQL&gt; SELECT 
&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;snap_id, begin_interval_time, end_interval_time 
&nbsp;&nbsp;3&nbsp;&nbsp;FROM 
&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;SYS.WRM$_SNAPSHOT 
&nbsp;&nbsp;5&nbsp;&nbsp;WHERE 
&nbsp;&nbsp;6&nbsp;&nbsp;&nbsp;&nbsp;snap_id = ( SELECT MIN (snap_id) FROM SYS.WRM$_SNAPSHOT)
&nbsp;&nbsp;7&nbsp;&nbsp;UNION 
&nbsp;&nbsp;8&nbsp;&nbsp;SELECT 
&nbsp;&nbsp;9&nbsp;&nbsp;&nbsp;&nbsp;snap_id, begin_interval_time, end_interval_time 
 10&nbsp;&nbsp;FROM 
 11&nbsp;&nbsp;&nbsp;&nbsp;SYS.WRM$_SNAPSHOT 
 12&nbsp;&nbsp;WHERE 
 13&nbsp;&nbsp;&nbsp;&nbsp;snap_id = ( SELECT MAX (snap_id) FROM SYS.WRM$_SNAPSHOT)
 14&nbsp;&nbsp;/
&nbsp;&nbsp; SNAP_ID BEGIN_INTERVAL_TIME&nbsp;&nbsp; END_INTERVAL_TIME
&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7556 <strong>15-09-07 08:44:42,810</strong> 15-09-07 11:01:11,950
&nbsp;&nbsp;&nbsp;&nbsp; 23698 18-08-09 11:00:41,612 18-08-09 12:00:53,074
&nbsp;
</pre>
<p>
<em><br />
I prefer SYS.WRM$_SNAPSHOT instead of DBA_HIST_SNAPSHOT because I saw strange results in (Release 10.1.0.5).<br />
</em><br />
Now use the dbms_workload_repository package to remove the AWR snapshots.
</p>
<pre>
BEGIN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;dbms_workload_repository.drop_snapshot_range(low_snap_id =&gt; 7556, high_snap_id=&gt;15000);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
END;
/
</pre>
<h3>Speed up &#8216;removal&#8217; of old AWR reports</h3>
<p>
@#$%^&#038;*()_ removing the entries takes ages and fails on undo errors &#8230; Metalink note Doc ID: 852028.1 states that I can safely remove the AWR metadata tables and recreate them.
</p>
<blockquote><p>
If none of the above suits as everything is set proper then consider clean up and rebuild AWR repository to clear all the space.
</p></blockquote>
<pre>
SQL&gt; connect / as sysdba 
SQL&gt; @?/rdbms/admin/catnoawr.sql 
SQL&gt; @?/rdbms/admin/catawrtb.sql 
</pre>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/oracle/purging-sysaux-tablespace-purging-awr-reports.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Restore SQL Server database with TSQL</title>
		<link>http://remidian.com/mssql/restore-sql-server-database-with-tsql.html</link>
		<comments>http://remidian.com/mssql/restore-sql-server-database-with-tsql.html#comments</comments>
		<pubDate>Wed, 25 Mar 2009 11:31:56 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://remidian.com/?p=98</guid>
		<description><![CDATA[Recently I had troubles restoring a database in my SQL Server 2005 instance (SP3). I used the &#8216;wizard&#8217; in the SQL Server Enterprise manager but after I got the message &#8216;restore completed successfully&#8217; the database hung in &#8216;Restoring&#8217; state, blocking connections. I decided the try to restore the database with T-SQL, with T-SQL the restore [...]]]></description>
			<content:encoded><![CDATA[<p>
Recently I had troubles restoring a database in my SQL Server 2005 instance (SP3). I used the &#8216;wizard&#8217; in the SQL Server Enterprise manager but after I got the message &#8216;restore completed successfully&#8217; the database hung in &#8216;Restoring&#8217; state, blocking connections.<span id="more-98"></span>
</p>
<p>
I decided the try to restore the database with T-SQL, with T-SQL the restore completed successfully! Another advantage of using T-SQL is that T-SQL gave more logging. This logging shows me that the BAK file (delivered from a third party) is not a SQL Server 2005 backup but presumably a SQL Server 2000 database backup &#8230;
</p>
<pre>
DECLARE
&nbsp;&nbsp;@BackupFile varchar(8000),
&nbsp;&nbsp;@sql varchar(8000)
&nbsp;&nbsp;SET @BackupFile = &#039;E:\DB2000.BAK&#039;
&nbsp;&nbsp;SET @sql = &#039;RESTORE DATABASE ADB01 FROM DISK = &#039;&#039;&#039; + @backupfile + &#039;&#039;&#039; WITH FILE = 1,&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;MOVE N&#039;&#039;DB2000_dat&#039;&#039; TO N&#039;&#039;E:\mssql\data\ADB01\ADB01_01.mdf&#039;&#039;,&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;MOVE N&#039;&#039;DB2000_log&#039;&#039; TO N&#039;&#039;F:\mssql\tlog\ADB01\ADB01_01.ldf&#039;&#039;,&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;NOUNLOAD,&nbsp;&nbsp;REPLACE,&nbsp;&nbsp;STATS = 10, RECOVERY&#039;
&nbsp;&nbsp;exec (@sql)
go
&nbsp;
10 percent processed.
20 percent processed.
30 percent processed.
40 percent processed.
50 percent processed.
60 percent processed.
70 percent processed.
80 percent processed.
90 percent processed.
100 percent processed.
Processed 2792 pages for database &#039;ADB01&#039;, file &#039;DB2000_dat&#039; on file 1.
Processed 1 pages for database &#039;ADB01&#039;, file &#039;DB2000_log&#039; on file 1.
Converting database &#039;ADB01&#039; from version 539 to the current version 611.
Database &#039;ADB01&#039; running the upgrade step from version 539 to version 551.
Database &#039;ADB01&#039; running the upgrade step from version 551 to version 552.
Database &#039;ADB01&#039; running the upgrade step from version 552 to version 553.
Database &#039;ADB01&#039; running the upgrade step from version 553 to version 554.
Database &#039;ADB01&#039; running the upgrade step from version 554 to version 589.
Database &#039;ADB01&#039; running the upgrade step from version 589 to version 590.
Database &#039;ADB01&#039; running the upgrade step from version 590 to version 593.
Database &#039;ADB01&#039; running the upgrade step from version 593 to version 597.
Database &#039;ADB01&#039; running the upgrade step from version 597 to version 604.
Database &#039;ADB01&#039; running the upgrade step from version 604 to version 605.
Database &#039;ADB01&#039; running the upgrade step from version 605 to version 606.
Database &#039;ADB01&#039; running the upgrade step from version 606 to version 607.
Database &#039;ADB01&#039; running the upgrade step from version 607 to version 608.
Database &#039;ADB01&#039; running the upgrade step from version 608 to version 609.
Database &#039;ADB01&#039; running the upgrade step from version 609 to version 610.
Database &#039;ADB01&#039; running the upgrade step from version 610 to version 611.
RESTORE DATABASE successfully processed 2793 pages in 1.513 seconds (15.118 MB/sec).
&nbsp;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/mssql/restore-sql-server-database-with-tsql.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>freaking hilarious incident&#8230;</title>
		<link>http://remidian.com/misc-2/freaking-hilarious-incident.html</link>
		<comments>http://remidian.com/misc-2/freaking-hilarious-incident.html#comments</comments>
		<pubDate>Mon, 22 Dec 2008 16:55:23 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://remidian.com/?p=77</guid>
		<description><![CDATA[**** production DB issue User ID :**** Phone :+**** Location :**** PC nr :**** Software/hardware :**** Problem &#038; TS : A job hangs in ****, Job name: **** User would like to be called back on the phone number provided if more information is needed. User said he cannot explain it to me because its [...]]]></description>
			<content:encoded><![CDATA[<p>
**** production DB issue<br />
User ID :****<br />
Phone :+****<br />
Location :****<br />
PC nr :****</p>
<p>Software/hardware :****<br />
Problem &#038; TS :<br />
A job hangs in ****,<br />
Job name: ****<br />
<strong><br />
User would like to be called back on the phone number provided if more information is needed.<br />
User said he cannot explain it to me because its too difficult to understand and i wouldnt understand anything anyways.<br />
**** production DB issue<br />
</strong></p>
<p>copy from call ticket 600-01-12184003 with incident ticket 600-02-6637739
</p>
<p>
hey team,<br />
talked with **** **** about this problem and she assigned it to your team.<br />
Can you please take a look at it?<br />
Thank you</p>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/misc-2/freaking-hilarious-incident.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manually triggering Metric Collection (clearing -tablespace- Alerts)</title>
		<link>http://remidian.com/oracle/grid/manually-triggering-metric-collection-clearing-alerts.html</link>
		<comments>http://remidian.com/oracle/grid/manually-triggering-metric-collection-clearing-alerts.html#comments</comments>
		<pubDate>Tue, 19 Feb 2008 09:28:50 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[Grid]]></category>

		<guid isPermaLink="false">http://remidian.com/oracle/grid/manually-triggering-metric-collection-clearing-alerts.html</guid>
		<description><![CDATA[Manually triggering metric collection in Oracle Enterprise Manager (GRID control) Here&#8217;s the scenario: You have an Alert that your tablespace is &#8216;full&#8217;, You enlarge the tablespace, The &#8216;Tablespace Full Alert&#8217; is still in your dashbord for the next 24 (x) hours since you&#8217;ve configured this metric to be collected once every 24 (x) hours, You [...]]]></description>
			<content:encoded><![CDATA[<p>Manually triggering metric collection in Oracle Enterprise Manager (GRID control)</p>
<p><span id="more-72"></span></p>
<p>
Here&#8217;s the scenario:
</p>
<ol>
<li>You have an Alert that your tablespace is &#8216;full&#8217;,</li>
<li>You enlarge the tablespace,</li>
<li>The &#8216;Tablespace Full Alert&#8217; is still in your dashbord for the next 24 (x) hours since you&#8217;ve configured this metric to be collected once every 24 (x) hours,</li>
<li>You <strong>want</strong> however to &#8216;remove&#8217; (clear) this Alert. In order to achive this you will have to to re-evaluate this metric collection &#8230;</li>
</ol>
<p>
Here is how you do it (for anything storage related on your database server):
</p>
<pre>
$ emctl control agent runCollection &lt;hostname&gt;:host host_storage
</pre>
<p>
See the Oracle docs, <a href="http://download.oracle.com/docs/cd/B19306_01/em.102/b40002/emctl.htm#sthref202<br />
">2.7.6 Reevaluating Metric Collections</a>. It shows you how to retrieve the correct <em>collection</em> name for any <em>metric</em>.
</p>
<p>
You will find yourself <code>grep</code>-ing through &#8216;$ORACLE_HOME/sysman/admin/metadata/*xml&#8217; and &#8216;$ORACLE_HOME/sysman/admin/default_collection/*xml&#8217; &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/oracle/grid/manually-triggering-metric-collection-clearing-alerts.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>osql switches</title>
		<link>http://remidian.com/mssql/osql.html</link>
		<comments>http://remidian.com/mssql/osql.html#comments</comments>
		<pubDate>Wed, 30 Jan 2008 15:01:52 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://remidian.com/mssql/osql.html</guid>
		<description><![CDATA[Some osql switches. Specify non default tcp ports C:\&#62;osql -Stcp:&#60;hostname&#62;,&#60;portname&#62;[\&#60;instance_name&#62;] -E 1&#62; See http://support.microsoft.com/kb/313295]]></description>
			<content:encoded><![CDATA[<p>
Some osql switches.<span id="more-71"></span>
</p>
<h3>
Specify non default tcp ports<br />
</h3>
<pre>
C:\&gt;osql -Stcp:&lt;hostname&gt;,&lt;portname&gt;[\&lt;instance_name&gt;] -E
1&gt;
</pre>
<p>
See http://support.microsoft.com/kb/313295</p>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/mssql/osql.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Increase idle time for OMS frontend sessions</title>
		<link>http://remidian.com/oracle/grid/increase-idle-time-for-oms-frontend-and-some-more-configuration-directives.html</link>
		<comments>http://remidian.com/oracle/grid/increase-idle-time-for-oms-frontend-and-some-more-configuration-directives.html#comments</comments>
		<pubDate>Mon, 28 Jan 2008 11:43:01 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[Grid]]></category>

		<guid isPermaLink="false">http://remidian.com/oracle/grid/increase-idle-time-for-oms-frontend-and-some-more-configuration-directives.html</guid>
		<description><![CDATA[Some additional configuration directives. To increase the idle time for the OMS frontend sessions edit the &#8216;oracle.sysman.eml.maxInactiveTime&#8217; configuration parameter your Oracle Management Server&#8217;s emoms.properties file. The parameter value unit is in minutes and the default is 15 minutes which is a bit short I suppose. I have set it to 4 hours as you can [...]]]></description>
			<content:encoded><![CDATA[<p>Some additional configuration directives.<span id="more-70"></span></p>
<p>
To increase the idle time for the OMS frontend sessions edit the &#8216;oracle.sysman.eml.maxInactiveTime&#8217; configuration parameter your Oracle Management Server&#8217;s emoms.properties file. The parameter value unit is in minutes and the default is 15 minutes which is a bit short I suppose. I have set it to 4 hours as you can see in the example below.
</p>
<pre>
$ cat $ORACLE_HOME/sysman/config/emoms.properties | grep maxInactiveTime
oracle.sysman.eml.maxInactiveTime=240
$
&nbsp;
</pre>
<p>
For more info see the &#8216;<a href="http://download.oracle.com/docs/cd/B19306_01/em.102/b40002/addnl_tasks.htm#sthref1347">Enterprise Manager Advanced Configuration</a>&#8216; book </p>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/oracle/grid/increase-idle-time-for-oms-frontend-and-some-more-configuration-directives.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove SQL Server database from single-user mode</title>
		<link>http://remidian.com/mssql/remove-sql-server-database-from-single-user-mode.html</link>
		<comments>http://remidian.com/mssql/remove-sql-server-database-from-single-user-mode.html#comments</comments>
		<pubDate>Wed, 23 Jan 2008 12:27:53 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[mssql]]></category>

		<guid isPermaLink="false">http://remidian.com/mssql/remove-sql-server-database-from-single-user-mode.html</guid>
		<description><![CDATA[Braindump of a session where I had to remove a SQL Server database from single-user mode. execute sp_dboption 1&#62; exec sp_dboption &#039;testdb01&#039;, &#039;single user&#039;, &#039;FALSE&#039;; 2&#62; go Msg 5064, Level 16, State 1, Server REMIDIAN01, Line 1 Changes to the state or options of database &#039;testdb01&#039; cannot be made at this time. The database is [...]]]></description>
			<content:encoded><![CDATA[<p>
Braindump of a session where I had to remove a SQL Server database from single-user mode.<span id="more-69"></span>
</p>
<h6>execute sp_dboption</h6>
<pre>
1&gt; exec sp_dboption &#039;testdb01&#039;, &#039;single user&#039;, &#039;FALSE&#039;;
2&gt; go
Msg 5064, Level 16, State 1, Server REMIDIAN01, Line 1
Changes to the state or options of database &#039;testdb01&#039; cannot be made at this
time. The database is in single-user mode, and a user is currently connected to
it.
Msg 5069, Level 16, State 1, Server REMIDIAN01, Line 1
ALTER DATABASE statement failed.
sp_dboption command failed.
</pre>
<p>
Now I can use TSQL below to find all the database sesions connected to this database.
</p>
<h6>
TSQL script to retrieve client sessions per database.<br />
</h6>
<pre>
select d.name, d.dbid, spid, login_time, nt_domain, nt_username, loginame
&nbsp;&nbsp;from sysprocesses p inner join sysdatabases d on p.dbid = d.dbid
 where d.name = &#039;testdb01&#039;
go
&nbsp;
</pre>
<p>
Kill the particular session(s) with the ;kill&#8217; command.
</p>
<pre>
1&gt; kill 51
2&gt; go
1&gt;
</pre>
<p>
Now I can &#8216;remove&#8217; the database from Sinlge user mode.
</p>
<pre>
1&gt; exec sp_dboption &#039;testdb01&#039;, &#039;single user&#039;, &#039;FALSE&#039;
2&gt; go
1&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/mssql/remove-sql-server-database-from-single-user-mode.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Batch SQL statements in parallel (multiple) sessions</title>
		<link>http://remidian.com/oracle/dba-util/batch-sql-in-parallel.html</link>
		<comments>http://remidian.com/oracle/dba-util/batch-sql-in-parallel.html#comments</comments>
		<pubDate>Fri, 18 Jan 2008 17:39:58 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[DBA util]]></category>

		<guid isPermaLink="false">http://remidian.com/oracle/dba-util/batch-sql-in-parallel.html</guid>
		<description><![CDATA[So it was decided &#8216;this batch&#8217; had to be done &#8216;this weekend&#8217;. Thousands of SQL statements some of them would take minutes others hours&#8230; And MAKE SURE it&#8217;s finished monday. I hate babysitting multiple sessions having to create multiple SQL Scripts to spread the workload (it&#8217;s on a 20+ CPUS&#8217;s database server) So I wrote [...]]]></description>
			<content:encoded><![CDATA[<p>So it was decided &#8216;this batch&#8217; had to be done &#8216;this weekend&#8217;. Thousands of SQL statements some of them would take minutes others hours&#8230; And MAKE SURE it&#8217;s finished monday.<span id="more-68"></span>
<p>
I hate babysitting <em>multiple</em> sessions having to create <em>multiple</em> SQL Scripts to spread the workload (it&#8217;s on a 20+ CPUS&#8217;s database server) So I wrote this PL/SQL &#8216;application&#8217; in a hurry to enable starting multiple databases sessions in <code>nohup</code>, each session picks up the next SQL statement &#8216;available&#8217; (WHERE endtime IS NULL). It will save me some sleep.
</p>
<h3>Setup</h3>
<h6>The table holding my SQL statements</h6>
<pre>
CREATE TABLE batchsql
 ( batchid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR2(64)&nbsp;&nbsp;&nbsp;&nbsp;NOT NULL
 , sqlid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT NULL UNIQUE
 , sqltext&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;varchar2(4000)&nbsp;&nbsp;NOT NULL
 , starttime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATE
 , endtime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATE
 , sqlcode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER
 , sqlerrm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR2(256)
 , error_stack&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR2(4000)
 , error_backtrace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR2(4000)
 );
</pre>
<p><em>would be nicer to make the &#8216;sqlid&#8217; column a compisone unique key with the batchid (harmless off course).</em></p>
<h6>The anonymous PL/SQL block that will loop and execute these statements</h6>
<pre>
DECLARE
&nbsp;&nbsp;v_batchid&nbsp;&nbsp;batchsql.batchid%TYPE;
&nbsp;&nbsp;i_sqlid&nbsp;&nbsp;&nbsp;&nbsp;batchsql.sqlid%TYPE;
&nbsp;&nbsp;v_sqltext&nbsp;&nbsp;batchsql.sqltext%TYPE;
&nbsp;
&nbsp;&nbsp;i_sqlcode&nbsp;&nbsp;PLS_INTEGER;
&nbsp;&nbsp;v_sqlerrm&nbsp;&nbsp;VARCHAR2(256);
&nbsp;
&nbsp;&nbsp;i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PLS_INTEGER;
&nbsp;
BEGIN
&nbsp;
<strong>&nbsp;&nbsp;v_batchid := &#039;DB01_ANALYZE_20080118&#039;;</strong>
&nbsp;&nbsp;i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; := 0;
&nbsp;
&nbsp;&nbsp;LOOP
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&#45;- get statement that nobody is working on
&nbsp;&nbsp;&nbsp;&nbsp;SELECT sqlid,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqltext
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTO i_sqlid,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_sqltext
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM batchsql
&nbsp;&nbsp;&nbsp;&nbsp; WHERE batchid = v_batchid
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND starttime IS NULL
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND rownum = 1;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;i := i +1;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&#45;- open new block for &#039;sqltext&#039; statement
&nbsp;&nbsp;&nbsp;&nbsp;BEGIN
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- first set the starttime, (lock statement) to make sure 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- no other session will pick up the same statement
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UPDATE batchsql
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET starttime = SYSDATE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE sqlid = i_sqlid;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;COMMIT;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- execute the statement
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EXECUTE IMMEDIATE v_sqltext;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- everything went well, register endtime and commit
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UPDATE batchsql
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET endtime = SYSDATE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE sqlid = i_sqlid;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;COMMIT;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;EXCEPTION
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHEN OTHERS THEN
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- error occured, register endtime and errors
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i_sqlcode := SQLCODE;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v_sqlerrm := SQLERRM;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UPDATE batchsql
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET endtime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= SYSDATE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , sqlcode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= i_sqlcode
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , sqlerrm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= v_sqlerrm
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , error_stack&nbsp;&nbsp;= DBMS_UTILITY.FORMAT_ERROR_STACK()
&#45;- Uncomment &#039;FORMAT_ERROR_BACKTRACE()&#039; for pre 10G
&#45;- , error_backtrace = DBMS_UTILITY.FORMAT_ERROR_BACKTRACE()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE sqlid = i_sqlid;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;COMMIT;
&nbsp;&nbsp;&nbsp;&nbsp;END;
&nbsp;
&nbsp;&nbsp;END LOOP;
&nbsp;
EXCEPTION
&nbsp;&nbsp;WHEN NO_DATA_FOUND THEN
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;IF i = 0 THEN
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBMS_OUTPUT.PUT_LINE ( &#039;No SQL Statements found for batch &#039;&#039;&#039; || v_batchid || &#039;&#039;&#039;&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;ELSE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBMS_OUTPUT.PUT_LINE ( &#039;Carried out &#039; || TO_CHAR(i) || &#039; SQL statements&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;END IF;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;DBMS_OUTPUT.PUT_LINE ( &#039;Time is &#039;&#039;&#039; || to_CHAR(SYSDATE, &#039;DD-MON-YY hh24:mi:ss&#039;) || &#039;&#039;&#039;&#039;);
&nbsp;
END;
/
&nbsp;
</pre>
<h3>Example</h3>
<p>
Suppose I have to analyze a bunch of tables, I will first have to fill my &#8216;batchsql&#8217; table with all the SQL Statements that belong to this batch, I identify the batch to &#8216;DB01_ANALYZE_20080118&#8242;.
</p>
<h6>Generate some SQL statements and insert them in the batchsql table</h6>
<pre>
SQL&gt; DEFINE BATCHID&nbsp;&nbsp;= &quot;&#039;&#039;DB01_ANALYZE_20080118&#039;&#039;&quot;
SQL&gt; DEFINE QUOTE&nbsp;&nbsp;&nbsp;&nbsp;= &quot;&#039;&#039;&quot;
SQL&gt; SELECT &#039;INSERT INTO batchsql 
&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( batchid, sqlid, sqltext)
&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VALUES
&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( &amp;BATCHID,&#039; || ROWNUM || &#039;, &amp;QUOTE.ANALYZE TABLE &#039; || table_name || &#039; COMPUTE STATISTICS&amp;QUOTE);&#039;
&nbsp;&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp; FROM user_tables
&nbsp;&nbsp;6&nbsp;&nbsp;&nbsp;&nbsp;WHERE rownum &lt; 5
&nbsp;&nbsp;7&nbsp;&nbsp;/
&#039;INSERTINTOBATCHSQL(BATCHID,SQLID,SQLTEXT)VALUES(&#039;&#039;DB01_ANALYZE_20080118&#039;&#039;,&#039;||ROWNUM||&#039;,&#039;&#039;ANALYZETABLE&#039;||TABLE_
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-
INSERT INTO batchsql
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( batchid, sqlid, sqltext)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VALUES
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( &#039;DB01_ANALYZE_20080118&#039;,1, &#039;ANALYZE TABLE BATCHSQL COMPUTE STATISTICS&#039;);
&nbsp;
INSERT INTO batchsql
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( batchid, sqlid, sqltext)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VALUES
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( &#039;DB01_ANALYZE_20080118&#039;,2, &#039;ANALYZE TABLE DEMO COMPUTE STATISTICS&#039;);
&nbsp;
SQL&gt; 
</pre>
<p>
Do test the error handling I insert one bogus statement that will generate an error.
</p>
<pre>
SQL&gt; INSERT INTO batchsql
&nbsp;&nbsp;2&nbsp;&nbsp; ( batchid, sqlid, sqltext)
&nbsp;&nbsp;3&nbsp;&nbsp; VALUES
&nbsp;&nbsp;4&nbsp;&nbsp; ( &#039;DB01_ANALYZE_20080118&#039;, 5, &#039;HELLO WORLD!&#039;);
&nbsp;
1 row created.
&nbsp;
SQL&gt; 
SQL&gt; 
</pre>
<p>
Now look at the contents of the batchsql table, we see three statements for the &#8216;DB01_ANALYZE_20080118&#8242; batch.
</p>
<pre>
SQL&gt; select batchid, sqlid, sqltext, starttime, endtime, sqlcode, sqlerrm from batchsql;
BATCHID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SQLID SQLTEXT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STARTTIME ENDTIME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SQLCODE SQLERRM
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-
DB01_ANALYZE_20080118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5 HELLO WORLD!
DB01_ANALYZE_20080118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 ANALYZE TABLE BATCHSQL COMPUTE STATISTICS
DB01_ANALYZE_20080118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 ANALYZE TABLE DEMO COMPUTE STATISTICS
&nbsp;
SQL&gt; 
</pre>
<p>Start a session that will start executing statements found in the batchsql table for batch &#8216;DB01_ANALYZE_20080118&#8242;:</p>
<pre>
SQL&gt; ed
Wrote file afiedt.buf
&nbsp;
&nbsp;&nbsp;1&nbsp;&nbsp;DECLARE
&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;v_batchid&nbsp;&nbsp;batchsql.batchid%TYPE;
&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;i_sqlid&nbsp;&nbsp;&nbsp;&nbsp;batchsql.sqlid%TYPE;
&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;v_sqltext&nbsp;&nbsp;batchsql.sqltext%TYPE;
&nbsp;&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;i_sqlcode&nbsp;&nbsp;PLS_INTEGER;
&nbsp;&nbsp;6&nbsp;&nbsp;&nbsp;&nbsp;v_sqlerrm&nbsp;&nbsp;VARCHAR2(256);
&nbsp;&nbsp;7&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PLS_INTEGER;
&nbsp;&nbsp;8&nbsp;&nbsp;BEGIN
&nbsp;&nbsp;9&nbsp;&nbsp;&nbsp;&nbsp;v_batchid := &#039;DB01_ANALYZE_20080118&#039;;
 10&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;&nbsp;&nbsp;&nbsp; := 0;
 11&nbsp;&nbsp;&nbsp;&nbsp;LOOP
 12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- get statement that nobody is working on
 13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT sqlid,
 14&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqltext
 15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTO i_sqlid,
 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_sqltext
 17&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM batchsql
 18&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE batchid = v_batchid
 19&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND starttime IS NULL
 20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND rownum = 1;
 21&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i := i +1;
 22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- open new block for &#039;sqltext&#039; statement
 23&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BEGIN
 24&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- first set the starttime, (lock statement) to make sure
 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- no other session will pick up the same statement
 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UPDATE batchsql
 27&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET starttime = SYSDATE
 28&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE sqlid = i_sqlid;
 29&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;COMMIT;
 30&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- execute the statement
 31&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EXECUTE IMMEDIATE v_sqltext;
 32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- everything went well, register endtime and commit
 33&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UPDATE batchsql
 34&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET endtime = SYSDATE
 35&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE sqlid = i_sqlid;
 36&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;COMMIT;
 37&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EXCEPTION
 38&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHEN OTHERS THEN
 39&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#45;- error occured, register endtime and errors
 40&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i_sqlcode := SQLCODE;
 41&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v_sqlerrm := SQLERRM;
 42&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UPDATE batchsql
 43&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET endtime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= SYSDATE
 44&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , sqlcode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= i_sqlcode
 45&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , sqlerrm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= v_sqlerrm
 46&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , error_stack&nbsp;&nbsp;= DBMS_UTILITY.FORMAT_ERROR_STACK()
 47&nbsp;&nbsp;&#45;- Uncomment &#039;FORMAT_ERROR_BACKTRACE()&#039; for pre 10G
 48&nbsp;&nbsp;&#45;- , error_backtrace = DBMS_UTILITY.FORMAT_ERROR_BACKTRACE()
 49&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE sqlid = i_sqlid;
 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;COMMIT;
 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;END;
 52&nbsp;&nbsp;&nbsp;&nbsp;END LOOP;
 53&nbsp;&nbsp;EXCEPTION
 54&nbsp;&nbsp;&nbsp;&nbsp;WHEN NO_DATA_FOUND THEN
 55&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IF i = 0 THEN
 56&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBMS_OUTPUT.PUT_LINE ( &#039;No SQL Statements found for batch &#039;&#039;&#039; || v_batchid || &#039;&#039;&#039;&#039;);
 57&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ELSE
 58&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBMS_OUTPUT.PUT_LINE ( &#039;Carried out &#039; || TO_CHAR(i) || &#039; SQL statements&#039;);
 59&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;END IF;
 60&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBMS_OUTPUT.PUT_LINE ( &#039;Time is &#039;&#039;&#039; || to_CHAR(SYSDATE, &#039;DD-MON-YY hh24:mi:ss&#039;) || &#039;&#039;&#039;&#039;);
 61* END;
 62&nbsp;&nbsp;/
Carried out 3 SQL statements
Time is &#039;18-JAN-08 18:37:01&#039;
&nbsp;
PL/SQL procedure successfully completed.
&nbsp;
SQL&gt; REM and again
SQL&gt; /
No SQL Statements found for batch &#039;DB01_ANALYZE_20080118&#039;
Time is &#039;18-JAN-08 18:37:20&#039;
&nbsp;
PL/SQL procedure successfully completed.
&nbsp;
SQL&gt; 
SQL&gt; 
</pre>
<p>
Pretty straigh forward, not?
</p>
<ul>
<li>The first run the starttime column is NULL (for every row),</li>
<li>The statements are executed, both the starttime and the endtime are updated at every single execution</li>
<li>The second run find no rows where starttime IS NULL and will not execute any statement at all.</li>
</ul>
<p>
See the log results.
</p>
<pre>
SQL&gt; select batchid, sqlid, sqltext, starttime, endtime, sqlcode, sqlerrm from batchsql;
BATCHID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SQLID SQLTEXT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STARTTIME ENDTIME&nbsp;&nbsp; SQLCODE SQLERRM
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;--
DB01_ANALYZE_20080118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5 HELLO WORLD!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 18-JAN-08 18-JAN-08&nbsp;&nbsp;&nbsp;&nbsp;-900 ORA-00900: invalid S
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;QL statement
&nbsp;
DB01_ANALYZE_20080118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 ANALYZE TABLE BATCHSQL COMPUTE STATISTICS&nbsp;&nbsp;18-JAN-08 18-JAN-08
DB01_ANALYZE_20080118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 ANALYZE TABLE DEMO COMPUTE STATISTICS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;18-JAN-08 18-JAN-08
&nbsp;
SQL&gt; 
</pre>
<p>
Of course, you can add extra functionalities as many as you would like, store the sessionid for every SQL statement, have multiple runs for a batch to reuse statements, etc etc. Oh and of course I should rewrite it to a SQL Procedure or Package.
</p>
<p>
The babysitting is now minimized to running this query:
</p>
<pre>
&nbsp;
col batch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for 9999
col completed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for 9999
col todo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for 9999
col activesessions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for 9999999&nbsp;&nbsp;&nbsp;&nbsp; head &quot;ACTIVE|SESSIONS&quot;
col errors&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for 99999
col elapsed_seconds&nbsp;&nbsp;&nbsp;&nbsp; for 9999999&nbsp;&nbsp;&nbsp;&nbsp; head &quot;ELAPSED|SECONDS&quot;
col avg_execution_time&nbsp;&nbsp;for 9999999&nbsp;&nbsp;&nbsp;&nbsp; head &quot;AVG|EXECUTION|TIME&quot;
col percentage_complete for 9999999&nbsp;&nbsp;&nbsp;&nbsp; head &quot;PERCENTAGE|COMPLETE&quot;
&nbsp;
&#45;- as I only have one batch loaded I don&#039;t need to filter on the batchid
select batch.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp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; trunc( ( sysdate - times.started)*24*60*60 / completed.c)&nbsp;&nbsp;avg_execution_time,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; to_char( sysdate +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( batch.c - completed.c) *
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( (sysdate - times.started) / completed.c)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , &#039;DD-MM-HH hh24:mi&#039;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;est_end_time
 from ( select count(*) as c from batchsql )&nbsp;&nbsp;&nbsp;&nbsp;batch
&nbsp;&nbsp;&nbsp;&nbsp;, ( select count(*) as c from batchsql
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where endtime is not null)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; completed
&nbsp;&nbsp;&nbsp;&nbsp;, ( select count(*) as c
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from batchsql
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where starttime is not null
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and endtime is null)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; activesessions
&nbsp;&nbsp;&nbsp;&nbsp;, ( select count(*) as c
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from batchsql
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where sqlcode is not null )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errors
&nbsp;&nbsp; , ( select min(starttime) started,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;max(starttime) lastcompleted
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from batchsql )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; times
/
&nbsp;
</pre>
<pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AVG
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PERCENTAGE&nbsp;&nbsp; ACTIVE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ELAPSED EXECUTION
BATCH COMPLETED&nbsp;&nbsp;TODO STARTED&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LASTCOMPLETED&nbsp;&nbsp;&nbsp;&nbsp;COMPLETE SESSIONS ERRORS&nbsp;&nbsp;SECONDS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TIME EST_END_TIME
&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;--
 1524&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 492&nbsp;&nbsp;1032 18-01-06 18:45 18-01-10 22:01&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;11756&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;23 19-01-04 04:52
&nbsp;
SQL&gt; 
SQL&gt; 
SQL&gt; select*from batchsql where sqlcode is not null;
BATCHID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLID
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
SQLTEXT
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;--
STARTTIME&nbsp;&nbsp;ENDTIME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCODE SQLERRM
&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;--
ERROR_STACK
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;--
ERROR_BACKTRACE
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;--
DB01_ANALYZE_20080118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;84
ANALYZE TABLE ********
18-01-2008 18-01-2008&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-1555 ORA-01555: snapshot too old: rollback segment number 2 with name &quot;_SYSSMU2$&quot; too small
ORA-01555: snapshot too old: rollback segment number 2 with name &quot;_SYSSMU2$&quot; too small
&nbsp;
SQL&gt; 
&nbsp;
</pre>
<h3>UPDATE 2010-05-10T11:04:21+00:00</h3>
<p>
Make sqlid non unique and add trigger to generate sqlid&#8217;s.
</p>
<pre>
CREATE TABLE batchsql
 ( batchid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR2(64)&nbsp;&nbsp;&nbsp;&nbsp;NOT NULL
 , sqlid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOT NULL
 , sqltext&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;varchar2(4000)&nbsp;&nbsp;NOT NULL
 , starttime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATE
 , endtime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATE
 , sqlcode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INTEGER
 , sqlerrm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR2(256)
 , error_stack&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR2(4000)
 , error_backtrace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR2(4000)
 );
&nbsp;
CREATE SEQUENCE s_batchsql;
&nbsp;
CREATE OR REPLACE TRIGGER t_batchsql
BEFORE INSERT ON batchsql
FOR EACH ROW
WHEN (new.sqlid IS NULL)
BEGIN
&nbsp;&nbsp;SELECT s_batchsql.NEXTVAL
&nbsp;&nbsp;INTO&nbsp;&nbsp; :new.sqlid
&nbsp;&nbsp;FROM&nbsp;&nbsp; dual;
END;
/
</pre>
<p>
Create script to execute statements from batch table
</p>
<pre>
export ORAENV_ASK=NO;
export ORACLE_SID=sfsse001;
/usr/local/bin/oraenv
&nbsp;
sqlplus -silent &#039;/ as sysdba&#039; &lt;&lt;EOF
&nbsp;
column d new_value d
select to_char( sysdate, &#039;YYYYMMDD-HH24MISS&#039;) d from dual;
&nbsp;
set serveroutput on
&nbsp;
spool batch_&amp;d.log
&nbsp;
@r.sql
&nbsp;
spool off
&nbsp;
EOF
&nbsp;
</pre>
<pre>
$ nohup r.sh &amp;
&nbsp;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/oracle/dba-util/batch-sql-in-parallel.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Really delete (&#8216;corrupt&#8217;) Agent from OMS repository</title>
		<link>http://remidian.com/oracle/grid/agent-corruption-status-in-oms.html</link>
		<comments>http://remidian.com/oracle/grid/agent-corruption-status-in-oms.html#comments</comments>
		<pubDate>Thu, 17 Jan 2008 13:42:05 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[Grid]]></category>

		<guid isPermaLink="false">http://remidian.com/oracle/grid/agent-corruption-status-in-oms.html</guid>
		<description><![CDATA[Here&#8217;s how to overcome ORA-20206 in Oracle GRID environment, agent status unclear&#8230; Scenario Removed (Windows) Agent from Grid. (With SQL Server Management plugin) Tried to restart this SAME agent, errors below occur. # $ORACLE_HOME/sysman/log/emagent.log contains &#160; 2008-01-17 14:13:52 Thread-4032 EMAgent started successfully (00702) 2008-01-17 14:14:21 Thread-2720 &#60;Upload Manager&#62; Unsuccessful Upload attempts for XML file exceeds [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to overcome ORA-20206 in Oracle GRID environment, agent status unclear&#8230;<span id="more-67"></span></p>
<h3>
Scenario<br />
</h3>
<ul>
<li>Removed (Windows) Agent from Grid. (With SQL Server Management plugin)</li>
<li>Tried to restart this SAME agent, errors below occur.</li>
</ul>
<pre>
# $ORACLE_HOME/sysman/log/emagent.log contains
&nbsp;
2008-01-17 14:13:52 Thread-4032 EMAgent started successfully (00702)
2008-01-17 14:14:21 Thread-2720 &lt;Upload Manager&gt; Unsuccessful Upload attempts for XML file exceeds specified limit=3, 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Agent will shutdown (00851)
2008-01-17 14:14:21 Thread-4032 EMAgent abnormal terminating (00704)
</pre>
<pre>
# $ORACLE_HOME/sysman/log/emdctl.trc contains
&nbsp;
2008-01-17 14:13:32 Thread-752 WARN&nbsp;&nbsp;http: snmehl_connect: connect failed to (&lt;agent_hostname&gt;:3872): 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;No connection could be made because the target machine actively refused it.
 (error = 10061)
2008-01-17 14:13:32 Thread-752 ERROR main: nmectla_agentctl: Error connecting to 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;https://&lt;agent_hostname&gt;:3872/emd/main/. Returning status code 1
2008-01-17 14:14:23 Thread-172 WARN&nbsp;&nbsp;http: snmehl_connect: connect failed to 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&lt;agent_hostname&gt;:3872): 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;No connection could be made because the target machine actively refused it. (error = 10061)
2008-01-17 14:14:23 Thread-172 ERROR main: nmectla_agentctl: Error connecting to 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;https://&lt;agent_hostname&gt;:3872/emd/main/. Returning status code 1
&nbsp;
</pre>
<pre>
# $ORACLE_HOME/sysman/log/emagent.trc contains
&nbsp;
2008-01-17 14:14:18 Thread-192 WARN&nbsp;&nbsp;TargetManager: Regenerating all Metadata
2008-01-17 14:14:18 Thread-192 DEBUG TargetManager: In getTypeAndNameForHostTarget
2008-01-17 14:14:18 Thread-192 DEBUG TargetManager: getTypeAndNameForHostTarget found host, &lt;agent_hostname&gt;
2008-01-17 14:14:18 Thread-192 DEBUG TargetManager: In getTypeAndNameForHostTarget
2008-01-17 14:14:18 Thread-192 DEBUG TargetManager: getTypeAndNameForHostTarget found host, &lt;agent_hostname&gt;
2008-01-17 14:14:18 Thread-192 WARN&nbsp;&nbsp;collector: Regenerating all DefaultColls
2008-01-17 14:14:18 Thread-192 ERROR upload: Failed to upload file A0000001.xml, ret = -6
2008-01-17 14:14:19 Thread-192 WARN&nbsp;&nbsp;upload: FxferSend: received fatal error in header from repository: 
&nbsp;
https://&lt;oms_hostname&gt;:1159/em/upload
&nbsp;
FATAL_ERROR::500|ORA-20206: Target does not exist:&nbsp;&nbsp;Agent does not exist for https://&lt;agent_hostname&gt;:3872/emd/main/
ORA-06512: at &quot;SYSMAN.EMD_LOADER&quot;, line 1795
ORA-06512: at line 1
&nbsp;
.
.
.
&nbsp;
2008-01-17 14:14:21 Thread-2720 ERROR upload: number of fatal error exceeds the limit 3
2008-01-17 14:14:21 Thread-2720 ERROR upload: agent will shutdown now
2008-01-17 14:14:21 Thread-2720 ERROR : Signalled to Exit with status 55
2008-01-17 14:14:21 Thread-4032 ERROR main: EMAgent abnormal terminating
</pre>
<h3>
&#8216;Solution&#8217;<br />
</h3>
<p>
The status of the Agent is unclear, first thing to do is check the SYSMAN.MGMT$TARGET table, if your agent shows up here try to remove it using th OMS frontend or use methods below.
</p>
<pre>
[IAWE239@PGRIDC03.AH.NL:AHC536]
SQL&gt; exec sysman.mgmt_admin.cleanup_agent(&#039;&lt;agent_hostname&gt;:3872&#039;)
BEGIN sysman.mgmt_admin.cleanup_agent(&#039;&lt;agent_hostname&gt;:3872&#039;); END;
&nbsp;
*
ERROR at line 1:
ORA-20206: Target does not exist: &lt;agent_hostname&gt;:3872
ORA-06512: at &quot;SYSMAN.MGMT_ADMIN&quot;, line 788
ORA-06512: at line 1
&nbsp;
[IAWE239@PGRIDC03.AH.NL:AHC536]
SQL&gt; exec sysman.mgmt_admin.delete_target_internal(&#039;&lt;agent_hostname&gt;:3872&#039;, &#039;oracle_emd&#039;);
BEGIN sysman.mgmt_admin.delete_target_internal(&#039;&lt;agent_hostname&gt;:3872&#039;, &#039;oracle_emd&#039;); END;
&nbsp;
*
ERROR at line 1:
ORA-20206:&nbsp;&nbsp;The target does not exist or may have already been deleted:&nbsp;&nbsp;Target name = &lt;agent_hostname&gt;:3872 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and Target type = oracle_emd
ORA-06512: at &quot;SYSMAN.MGMT_ADMIN&quot;, line 645
ORA-06512: at line 1
</pre>
<p>
Now check the records in SYSMAN.MGMT_TARGETS_DELETE
</p>
<pre>
[IAWE239-SYSMAN@PGRIDC03.AH.NL:AHC536]
SQL&gt; SELECT target_name, delete_complete_time, target_guid
&nbsp;&nbsp;2&nbsp;&nbsp;FROM sysman.mgmt_targets_delete
&nbsp;&nbsp;3&nbsp;&nbsp;WHERE target_type = &#039;oracle_emd&#039;;
&nbsp;
TARGET_NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DELETE_COM TARGET_GUID
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;--
&lt;agent_hostname&gt;:3872&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;17-01-2008 CACA6898BA9051954366482B01EBE9CB
&nbsp;
</pre>
<p>
Oooops, my agent should have been correcly removed&#8230;
</p>
<h3>Really, really, REALLY remove agent from OMS repository</h3>
<p>
Sick and tired of this I decided &#8216;solution&#8217; below: select/remove all recors with GUID of my Agent.
</p>
<pre>
DEFINE TARGET_GUID = &quot;CACA6898BA9051954366482B01EBE9CB&quot;
&nbsp;
SELECT&nbsp;&nbsp; &#039;SELECT COUNT(*) FROM &#039; || table_name || &#039; WHERE target_guid = HEXTORAW(&#039;&#039;&amp;TARGET_GUID&#039;&#039;);&#039;
&#45;- SELECT&nbsp;&nbsp; &#039;DELETE FROM &#039; || table_name || &#039; WHERE target_guid = HEXTORAW(&#039;&#039;&amp;TARGET_GUID&#039;&#039;);&#039;
FROM&nbsp;&nbsp; ( SELECT table_name FROM dba_tab_columns NATURAL JOIN dba_tables WHERE column_name = &#039;TARGET_GUID&#039;)
/
&nbsp;
SQL&gt; REM Or check ALL raw columns

SELECT &#039;SELECT COUNT(*) FROM &#039; || table_name || &#039; WHERE &#039; || column_name || &#039; = HEXTORAW(&#039;&#039;&amp;TARGET_GUID&#039;&#039;);&#039;
&nbsp;&nbsp;FROM ( 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT table_name, column_name 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM dba_tab_columns NATURAL JOIN dba_tables 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE owner = &#039;SYSMAN&#039; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AND data_type = &#039;RAW&#039; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )
/
&nbsp;
</pre>
<p>
In my environment there was a mismatch between the MGMT_TARGETS and the MGMT_AGENT_SEC_INFO:
</p>
<pre>
SQL&gt; SELECT COUNT(*) FROM mgmt_targets WHERE target_type = &#039;oracle_emd&#039; ;
&nbsp;&nbsp;COUNT(*)
&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;30
&nbsp;
SQL&gt; SELECT COUNT(*) FROM mgmt_agent_sec_info ;
&nbsp;&nbsp;COUNT(*)
&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;32
&nbsp;
SQL&gt; SELECT * FROM mgmt_agent_sec_info WHERE target_guid = HEXTORAW( &#039;&amp;TARGET_GUID&#039;);
TARGET_GUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AGENT_KEY
&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-
CACA6898BA9051954366482B01EBE9CB ¿¿¿¿.¿¿¿9¿2¿¿KM(¿&lt;+¿¿H¿¿¿¿!¿E&gt;¿¿
</pre>
<p>
<strong><br />
(Windows Only?) &#8216;emctl clearstate agent&#8217; does NOT remove XML files from $ORACLE_HOME/sysman/emd/upload, remove manually from the OS to prevent &#8216;Failed to upload file A0000001.xml&#8217; and &#8216;FxferSend: received fatal error in header from repository&#8217; errors.<br />
</strong>
</p>
<p>
Needless to say, use at your own risk; also see oracle forum thread <a href="http://forums.oracle.com/forums/thread.jspa?threadID=347619">delete old agent</a></p>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/oracle/grid/agent-corruption-status-in-oms.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clearing Alerts in Oracle GRID Control</title>
		<link>http://remidian.com/oracle/grid/clearing-alerts-in-oracle-grid-control.html</link>
		<comments>http://remidian.com/oracle/grid/clearing-alerts-in-oracle-grid-control.html#comments</comments>
		<pubDate>Mon, 12 Nov 2007 13:01:26 +0000</pubDate>
		<dc:creator>remivisser</dc:creator>
				<category><![CDATA[Grid]]></category>

		<guid isPermaLink="false">http://remidian.com/oracle/grid/clearing-alerts-in-enterprise-manager.html</guid>
		<description><![CDATA[Here&#8217;s how to clear alerts from the Oracle GRID manually. For some obscure reason Oracle is very reluctant in providing the information that is described here below. Search Metalink and you will find no entries&#8230; The information below is from dbasupport.com and helps me to clear alerts that the Agent does NOT clear for me. [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to clear alerts from the Oracle GRID manually.<span id="more-66"></span></p>
<p>
For some obscure reason Oracle is very reluctant in providing the information that is described here below. Search Metalink and you will find no entries&#8230; The information below is from <a href="http://www.dbasupport.com/oracle/ora10g/clearing_alerts.shtml">dbasupport.com</a> and helps me to clear alerts that the Agent does NOT clear for me.
</p>
<h6>sysman.em_severity</h6>
<pre>
[REMI@DB01.REMIDIAN.COM]
SQL&gt;&nbsp;&nbsp;@desc sysman.em_severity
.
.
PROCEDURE DELETE_CURRENT_SEVERITY
 Argument Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;In/Out Default?
 &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;-&#45;&#45;&#45;-- &#45;&#45;-&#45;&#45;- &#45;&#45;-&#45;&#45;&#45;--
 P_TARGET_GUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RAW&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IN
 P_METRIC_GUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RAW&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IN
 P_KEY_VALUE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VARCHAR2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IN
.
.
&nbsp;
</pre>
<h6>Generate SQL to remove alerts from specific targets</h6>
<pre>
select t.target_name
,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.target_type
,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;collection_timestamp
,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message
,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;exec em_severity.delete_current_severity(&#039;&#039;&#039; ||
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t.target_guid || &#039;&#039;&#039;,&#039;&#039;&#039; ||
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; metric_guid || &#039;&#039;&#039;,&#039;&#039;&#039; ||
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key_value || &#039;&#039;&#039;)&#039; em_severity
from&nbsp;&nbsp; mgmt_targets t
inner join
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mgmt_current_severity s
on
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t.target_guid = s.target_guid
where
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; target_name like &#039;&amp;TARGET&#039;
</pre>
<h6>Remove the Alert</h6>
<pre>
[REMI@DB01.REMIDIAN.COM]
SQL&gt; begin
&nbsp;&nbsp;2&nbsp;&nbsp;em_severity.delete_current_severity(&#039;3DFABFF28D9C283435DBD2491D35B92B&#039;,&#039;3E6F70DB22758B7B9756EF342180E7BB&#039;,&#039;UNDO&#039;);
&nbsp;&nbsp;3&nbsp;&nbsp;end;
&nbsp;&nbsp;4&nbsp;&nbsp;/
&nbsp;
PL/SQL procedure successfully completed.
&nbsp;
[REMI@DB01.REMIDIAN.COM]
SQL&gt; 
</pre>
]]></content:encoded>
			<wfw:commentRss>http://remidian.com/oracle/grid/clearing-alerts-in-oracle-grid-control.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
