<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: More Job Scheduling Examples with DBMS_JOB</title>
	<atom:link href="http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/</link>
	<description>because I don't believe in life before coffee...</description>
	<lastBuildDate>Wed, 28 Oct 2009 06:44:36 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jon</title>
		<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/comment-page-1/#comment-885</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Sun, 21 May 2006 21:20:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/#comment-885</guid>
		<description>I guess we have different philosophies Jonathan.  I think these are good examples as they might give a person some ideas for writing their own jobs.  They would serve the same purpose if they were written in pseudo-code.

I do say that these are examples of &lt;em&gt;complex&lt;/em&gt; job scheduling.  I&#039;d hope that someone who wants to use these examples has some understanding of the scheduler already, and therefore should be able to read past some of the inconsistencies.</description>
		<content:encoded><![CDATA[<p>I guess we have different philosophies Jonathan.  I think these are good examples as they might give a person some ideas for writing their own jobs.  They would serve the same purpose if they were written in pseudo-code.</p>
<p>I do say that these are examples of <em>complex</em> job scheduling.  I&#8217;d hope that someone who wants to use these examples has some understanding of the scheduler already, and therefore should be able to read past some of the inconsistencies.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/comment-page-1/#comment-772</link>
		<dc:creator>Jonathan Lewis</dc:creator>
		<pubDate>Fri, 19 May 2006 16:22:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/#comment-772</guid>
		<description>Jon,

Regarding:  &quot;Code is provided for educational purposes only&quot;.
I have no problem with people trying to explain something, and making the occasional mistake in the code they publish; after all an educational article that attempts to explain how something works may allow the reader to identify the error.  

I do have a bit of a problem with someone who directs people to a set of &quot;good examples&quot; without first checking the quality of those examples.


I note that the original error that I highlighted has been corrected in the source article, but re-reada that source and take note:


The very first example of dbms_job shows:
      what=&gt;&#039;statspack_alert.sql;&#039;, 
That almost looks as if the author is suggesting that dbms_job can run SQL scripts direct, doesn&#039;t it.


The second example shows:
     DBMS_JOB.isubmit (
Interesting - why have we switched to isubmit() - with no explanation.
Moreoever, this example is decsribed as running to run once every hour, but it is the only one which does something like this:
     interval =&gt; &#039;SYSDATE + 1/24 
Every other &quot;once every hour&quot; example uses 
     trunc(SYSDATE+1/24,&#039;&#039;HH&#039;&#039;)&#039;, 
Why the difference - and does it matter ?


The third and fourth examples are annotated (respectively) with:
    -- Submit job to begin at 0600 
    -- Submit job to begin at 0900 
but the code lines have there &#039;next_date&#039; set to:
    trunc(sysdate)+6/24, 
    trunc(sysdate+1)+9/24, 
So which one matches its description, and why ?


The fourth example is annotated with 
    -- Submit job to begin at 0600 and run every 10 minutes
but the code says:
    trunc(sysdate+1/144,&#039;MI&#039;),
Silly error - but just one little warning among many.

Then, the interval on this example is:
    &#039;trunc(sysdate+1/144,&#039;&#039;MI&#039;&#039;)&#039;, 

Now - is the interval calculated when the job starts, or when the job ends: and since the &#039;waht&#039; was apparently a default call to:
    ’statspack.snap;’,
what happens if the statspack.snap takes more than a minute - which can easily happen on a big system if you leave the statspack configuration to its default operation.


By all means, do your best to educate your readers - but don&#039;t tell them that something is good before you&#039;ve checked it very carefully. They&#039;re reading your material to find out how to do something; you owe it to them to make sure that the articles you direct them to are at least as good as the stuff you write yourself.</description>
		<content:encoded><![CDATA[<p>Jon,</p>
<p>Regarding:  &#8220;Code is provided for educational purposes only&#8221;.<br />
I have no problem with people trying to explain something, and making the occasional mistake in the code they publish; after all an educational article that attempts to explain how something works may allow the reader to identify the error.  </p>
<p>I do have a bit of a problem with someone who directs people to a set of &#8220;good examples&#8221; without first checking the quality of those examples.</p>
<p>I note that the original error that I highlighted has been corrected in the source article, but re-reada that source and take note:</p>
<p>The very first example of dbms_job shows:<br />
      what=&gt;&#8217;statspack_alert.sql;&#8217;,<br />
That almost looks as if the author is suggesting that dbms_job can run SQL scripts direct, doesn&#8217;t it.</p>
<p>The second example shows:<br />
     DBMS_JOB.isubmit (<br />
Interesting &#8211; why have we switched to isubmit() &#8211; with no explanation.<br />
Moreoever, this example is decsribed as running to run once every hour, but it is the only one which does something like this:<br />
     interval =&gt; &#8216;SYSDATE + 1/24<br />
Every other &#8220;once every hour&#8221; example uses<br />
     trunc(SYSDATE+1/24,&#8221;HH&#8221;)&#8217;,<br />
Why the difference &#8211; and does it matter ?</p>
<p>The third and fourth examples are annotated (respectively) with:<br />
    &#8212; Submit job to begin at 0600<br />
    &#8212; Submit job to begin at 0900<br />
but the code lines have there &#8216;next_date&#8217; set to:<br />
    trunc(sysdate)+6/24,<br />
    trunc(sysdate+1)+9/24,<br />
So which one matches its description, and why ?</p>
<p>The fourth example is annotated with<br />
    &#8212; Submit job to begin at 0600 and run every 10 minutes<br />
but the code says:<br />
    trunc(sysdate+1/144,&#8217;MI&#8217;),<br />
Silly error &#8211; but just one little warning among many.</p>
<p>Then, the interval on this example is:<br />
    &#8216;trunc(sysdate+1/144,&#8221;MI&#8221;)&#8217;, </p>
<p>Now &#8211; is the interval calculated when the job starts, or when the job ends: and since the &#8216;waht&#8217; was apparently a default call to:<br />
    ’statspack.snap;’,<br />
what happens if the statspack.snap takes more than a minute &#8211; which can easily happen on a big system if you leave the statspack configuration to its default operation.</p>
<p>By all means, do your best to educate your readers &#8211; but don&#8217;t tell them that something is good before you&#8217;ve checked it very carefully. They&#8217;re reading your material to find out how to do something; you owe it to them to make sure that the articles you direct them to are at least as good as the stuff you write yourself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/comment-page-1/#comment-738</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Wed, 17 May 2006 12:16:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/#comment-738</guid>
		<description>Thanks Tim.  I&#039;m looking forward to the 10g scheduler.  We&#039;re due to move most of our DBs to 10gR2 this summer.

Jon</description>
		<content:encoded><![CDATA[<p>Thanks Tim.  I&#8217;m looking forward to the 10g scheduler.  We&#8217;re due to move most of our DBs to 10gR2 this summer.</p>
<p>Jon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Hall</title>
		<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/comment-page-1/#comment-736</link>
		<dc:creator>Tim Hall</dc:creator>
		<pubDate>Wed, 17 May 2006 07:34:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/#comment-736</guid>
		<description>Hi.

This seems to work fine for me:

&#039;trunc(least(next_day(SYSDATE - 23/24,&#039;&#039;MONDAY&#039;&#039;),next_day(SYSDATE - 23/24,&#039;&#039;TUESDAY&#039;&#039;),next_day(SYSDATE - 23/24,&#039;&#039;WEDNESDAY&#039;&#039;),next_day(SYSDATE - 23/24,&#039;&#039;THURSDAY&#039;&#039;),next_day(SYSDATE - 23/24,&#039;&#039;FRIDAY&#039;&#039;)),&#039;&#039;HH&#039;&#039;)&#039;

Of course, it&#039;s much easier to use the 10g scheduler:

&#039;freq=hourly; byday=MON,TUE,WED,THU,FRI; byminute=0; bysecond=0;&#039;

:)

Cheers

Tim...</description>
		<content:encoded><![CDATA[<p>Hi.</p>
<p>This seems to work fine for me:</p>
<p>&#8216;trunc(least(next_day(SYSDATE &#8211; 23/24,&#8221;MONDAY&#8221;),next_day(SYSDATE &#8211; 23/24,&#8221;TUESDAY&#8221;),next_day(SYSDATE &#8211; 23/24,&#8221;WEDNESDAY&#8221;),next_day(SYSDATE &#8211; 23/24,&#8221;THURSDAY&#8221;),next_day(SYSDATE &#8211; 23/24,&#8221;FRIDAY&#8221;)),&#8221;HH&#8221;)&#8217;</p>
<p>Of course, it&#8217;s much easier to use the 10g scheduler:</p>
<p>&#8216;freq=hourly; byday=MON,TUE,WED,THU,FRI; byminute=0; bysecond=0;&#8217;</p>
<p> <img src='http://www.lifeaftercoffee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers</p>
<p>Tim&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/comment-page-1/#comment-714</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Mon, 15 May 2006 15:50:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/#comment-714</guid>
		<description>&lt;strong&gt;Another Update:&lt;/strong&gt;  To keep this from running at midnight on Saturday morming and make it run at midnight on Monday morning I have changed it to subtract 23 hours and skip adding the extra hour.

Don Burleson and folks point out that if the first running of this falls on a Saturday or Sunday it will not properly calculate the second running, but hey, you shouldn&#039;t work on weekends anyway.

Jon</description>
		<content:encoded><![CDATA[<p><strong>Another Update:</strong>  To keep this from running at midnight on Saturday morming and make it run at midnight on Monday morning I have changed it to subtract 23 hours and skip adding the extra hour.</p>
<p>Don Burleson and folks point out that if the first running of this falls on a Saturday or Sunday it will not properly calculate the second running, but hey, you shouldn&#8217;t work on weekends anyway.</p>
<p>Jon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/comment-page-1/#comment-644</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Wed, 10 May 2006 14:31:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/#comment-644</guid>
		<description>You&#039;re right Jonathan, I did not test this code.

Since the &lt;code&gt;next_day&lt;/code&gt; wants to pick the next day AFTER the date passed we can just subtract 1 from &lt;code&gt;sysdate&lt;/code&gt; and the interval will work.

I have updated the code in this post and I will ping the folks over at Burleson to do the same.

I feel it is better to put something out there with the risk of it being wrong than to not put anything out there at all.  Even a wrong answer can help get someone to the right solution.  In this case, someone using &lt;a href=&quot;http://www.lifeaftercoffee.com/2006/03/13/tom-kytes-rant/&quot;&gt;this information as a starting point as I have suggested in the past&lt;/a&gt; could take this code and get what they needed easily.

Code is provided here (and at most sites) &lt;strong&gt;for educational purposes only.&lt;/strong&gt;  While that may seem like a boilerplate label to avoid litigation, it &lt;em&gt;is&lt;/em&gt; the truth.

That having been said I encourage you to continue to leave comments when you find errors.  That is the great thing about blogging!  The ability for the community to give feedback and help improve the content.</description>
		<content:encoded><![CDATA[<p>You&#8217;re right Jonathan, I did not test this code.</p>
<p>Since the <code>next_day</code> wants to pick the next day AFTER the date passed we can just subtract 1 from <code>sysdate</code> and the interval will work.</p>
<p>I have updated the code in this post and I will ping the folks over at Burleson to do the same.</p>
<p>I feel it is better to put something out there with the risk of it being wrong than to not put anything out there at all.  Even a wrong answer can help get someone to the right solution.  In this case, someone using <a href="http://www.lifeaftercoffee.com/2006/03/13/tom-kytes-rant/">this information as a starting point as I have suggested in the past</a> could take this code and get what they needed easily.</p>
<p>Code is provided here (and at most sites) <strong>for educational purposes only.</strong>  While that may seem like a boilerplate label to avoid litigation, it <em>is</em> the truth.</p>
<p>That having been said I encourage you to continue to leave comments when you find errors.  That is the great thing about blogging!  The ability for the community to give feedback and help improve the content.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/comment-page-1/#comment-639</link>
		<dc:creator>Jonathan Lewis</dc:creator>
		<pubDate>Wed, 10 May 2006 07:22:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/#comment-639</guid>
		<description>Here&#039;s a funny thing - I stumbled on this posting when searching for an item where Don Burleson said that a comment I had made as &quot;more than stupid&quot; - and find an interesting take on the PGA article he wrote (for a different view point see: http://www.jlcomp.demon.co.uk/untested.html ) and explaining how 

But that&#039;s irrelevant at the moment. A point I&#039;d like to make is that before posting a statement that someone else&#039;s code examples are GOOD, it benefits everyone if you check that the code does what it claims. 

The INTERVAL in the example you&#039;ve quoted is defined as:

&#039; trunc(
    least(
        next_day(SYSDATE,&#039;&#039;MONDAY&#039;&#039;),
        next_day(SYSDATE,&#039;&#039;TUESDAY&#039;&#039;),
        next_day(SYSDATE,&#039;&#039;WEDNESDAY&#039;&#039;),
        next_day(SYSDATE,&#039;&#039;THURSDAY&#039;&#039;),
        next_day(SYSDATE,&#039;&#039;FRIDAY&#039;&#039;)
    )
    +1/24,&#039;HH&#039;&#039;)&#039;

next_day(sysdate,&#039;MONDAY&#039;) returns a date value with the first Monday AFTER sysdate as the date component, and the current time as the time component.  

So taking the LEAST() of the list supplied will 
give you a date/time in the NEXT WORKING DAY (i.e. skipping week-ends)

Adding 1/24 and truncating to the hour moves the time on to the next (complete) hour.

So this INTERVAL gives you one report per day, skipping week-ends, and moving the time of the interval forward by one extra hour each day. It does not &quot;run every hour, Monday - Friday&quot;.

Clearly, the code posted has not been tested properly.

Regards

Jonathan Lewis</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a funny thing &#8211; I stumbled on this posting when searching for an item where Don Burleson said that a comment I had made as &#8220;more than stupid&#8221; &#8211; and find an interesting take on the PGA article he wrote (for a different view point see: <a href="http://www.jlcomp.demon.co.uk/untested.html" rel="nofollow">http://www.jlcomp.demon.co.uk/untested.html</a> ) and explaining how </p>
<p>But that&#8217;s irrelevant at the moment. A point I&#8217;d like to make is that before posting a statement that someone else&#8217;s code examples are GOOD, it benefits everyone if you check that the code does what it claims. </p>
<p>The INTERVAL in the example you&#8217;ve quoted is defined as:</p>
<p>&#8216; trunc(<br />
    least(<br />
        next_day(SYSDATE,&#8221;MONDAY&#8221;),<br />
        next_day(SYSDATE,&#8221;TUESDAY&#8221;),<br />
        next_day(SYSDATE,&#8221;WEDNESDAY&#8221;),<br />
        next_day(SYSDATE,&#8221;THURSDAY&#8221;),<br />
        next_day(SYSDATE,&#8221;FRIDAY&#8221;)<br />
    )<br />
    +1/24,&#8217;HH&#8221;)&#8217;</p>
<p>next_day(sysdate,&#8217;MONDAY&#8217;) returns a date value with the first Monday AFTER sysdate as the date component, and the current time as the time component.  </p>
<p>So taking the LEAST() of the list supplied will<br />
give you a date/time in the NEXT WORKING DAY (i.e. skipping week-ends)</p>
<p>Adding 1/24 and truncating to the hour moves the time on to the next (complete) hour.</p>
<p>So this INTERVAL gives you one report per day, skipping week-ends, and moving the time of the interval forward by one extra hour each day. It does not &#8220;run every hour, Monday &#8211; Friday&#8221;.</p>
<p>Clearly, the code posted has not been tested properly.</p>
<p>Regards</p>
<p>Jonathan Lewis</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/comment-page-1/#comment-208</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Fri, 17 Feb 2006 18:29:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/#comment-208</guid>
		<description>The important detail to the circumstances is that I was mentioning it to another DBA who should then go look up how it works before he uses it.  I have looked it up before for specific commands and would look it up again before I used it.</description>
		<content:encoded><![CDATA[<p>The important detail to the circumstances is that I was mentioning it to another DBA who should then go look up how it works before he uses it.  I have looked it up before for specific commands and would look it up again before I used it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/comment-page-1/#comment-207</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Fri, 17 Feb 2006 16:47:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/#comment-207</guid>
		<description>&lt;blockquote&gt;Never run anything in your databases that doesn’t make sense to you. I may find a site that has exactly the code I’m looking for, but I’ll pull out the books and read up on it until I’m comfortable with all the commands it uses, then I’ll run it.&lt;/blockquote&gt;

Well...I just had a conversation with Jon in my office and it seems he likes to use the &#039;Force&#039; command all over the place saying &quot;Well, [I don&#039;t know what it means for sure], it seems to work nicely in some commands.&quot;</description>
		<content:encoded><![CDATA[<blockquote><p>Never run anything in your databases that doesn’t make sense to you. I may find a site that has exactly the code I’m looking for, but I’ll pull out the books and read up on it until I’m comfortable with all the commands it uses, then I’ll run it.</p></blockquote>
<p>Well&#8230;I just had a conversation with Jon in my office and it seems he likes to use the &#8216;Force&#8217; command all over the place saying &#8220;Well, [I don't know what it means for sure], it seems to work nicely in some commands.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/comment-page-1/#comment-205</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Fri, 17 Feb 2006 01:23:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.lifeaftercoffee.com/2006/02/15/more-job-scheduling-examples-with-dbms_job/#comment-205</guid>
		<description>Glad to see you get around in the blogosphere Don.

&gt;&gt; I’m really fat from 25 years of sitting in front of a terminal

Yeah, desk jobs aren&#039;t kind to any of us.  You&#039;ll notice there aren&#039;t any pictures of me on my site.

My advice to everyone is never run anything in your databases that doesn&#039;t make sense to you.  I may find a site that has exactly the code I&#039;m looking for, but I&#039;ll pull out the books and read up on it until I&#039;m comfortable with all the commands it uses, then I&#039;ll run it.  I&#039;d rather not have to say to my boss that &quot;I ran some code off the internet and I don&#039;t understand what happened&quot;.</description>
		<content:encoded><![CDATA[<p>Glad to see you get around in the blogosphere Don.</p>
<p>>> I’m really fat from 25 years of sitting in front of a terminal</p>
<p>Yeah, desk jobs aren&#8217;t kind to any of us.  You&#8217;ll notice there aren&#8217;t any pictures of me on my site.</p>
<p>My advice to everyone is never run anything in your databases that doesn&#8217;t make sense to you.  I may find a site that has exactly the code I&#8217;m looking for, but I&#8217;ll pull out the books and read up on it until I&#8217;m comfortable with all the commands it uses, then I&#8217;ll run it.  I&#8217;d rather not have to say to my boss that &#8220;I ran some code off the internet and I don&#8217;t understand what happened&#8221;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
