<?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>IONCANNON &#187; database administration</title>
	<atom:link href="http://www.ioncannon.net/category/database-administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ioncannon.net</link>
	<description>Thoughts on Software Development and Engineering</description>
	<lastBuildDate>Tue, 03 Jan 2012 13:59:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<atom:link rel='hub' href='http://www.ioncannon.net/?pushpress=hub'/>
		<item>
		<title>How to get the next date for a weekday using Oracle</title>
		<link>http://www.ioncannon.net/database-administration/93/how-to-get-the-next-date-for-a-weekday-using-oracle/</link>
		<comments>http://www.ioncannon.net/database-administration/93/how-to-get-the-next-date-for-a-weekday-using-oracle/#comments</comments>
		<pubDate>Wed, 02 Aug 2006 19:26:57 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[database administration]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/oracle/93/how-to-get-the-next-date-for-a-weekday-using-oracle/</guid>
		<description><![CDATA[If you ever need to find the next weekday from a given date in Oracle it turns out they have a built in function for doing just that. If you want the next Sunday from yesterday you would do: Valid entries for the day are: SUN, MON, TUE, WED, THU, FRI, and SAT Tags: Oracle, [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever need to find the next weekday from a given date in Oracle it turns out they have a built in function for doing just that. If you want the next Sunday from yesterday you would do:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">SELECT</span> NEXT_DAY<span class="br0">&#40;</span>SYSDATE <span class="sy0">-</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="st0">&#039;SUN&#039;</span><span class="br0">&#41;</span> <span class="kw1">FROM</span> dual;</div>
</div>
<p>Valid entries for the day are: SUN, MON, TUE, WED, THU, FRI, and SAT</p>
<p>Tags: <a href="http://technorati.com/tag/Oracle" rel="tag">Oracle</a>, <a href="http://technorati.com/tag/SQL" rel="tag"> SQL</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/database-administration/93/how-to-get-the-next-date-for-a-weekday-using-oracle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL Beautifier</title>
		<link>http://www.ioncannon.net/database-administration/67/sql-beautifier/</link>
		<comments>http://www.ioncannon.net/database-administration/67/sql-beautifier/#comments</comments>
		<pubDate>Thu, 06 Jul 2006 17:35:24 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[database administration]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/oracle/67/sql-beautifier/</guid>
		<description><![CDATA[I pulled a large amount of SQL out of some existing code and wanted to have it formated nicely for me. I figured there had to be some type of pretty printer for SQL available outside of applications like TOAD. I have access to TOAD but it would have required a reboot so I figured [...]]]></description>
			<content:encoded><![CDATA[<p>I pulled a large amount of SQL out of some existing code and wanted to have it formated nicely for me. I figured there had to be some type of pretty printer for SQL available outside of applications like TOAD. I have access to TOAD but it would have required a reboot so I figured I would ask google what to do. There seem to be a number of different formaters out there. I found a couple people talking about current options <a href="http://awads.net/wp/2005/12/12/format-your-sql-the-easy-way/">a list here</a> and <a href="http://blogs.ittoolbox.com/database/solutions/archives/free-sql-code-beautifier-3240">here</a>.  The following list is a summary of the options I found:</p>
<ul>
<li><a href="http://www.sqlinform.com/">SQLInform</a></li>
<li><a href="http://www.wangz.net/cgi-bin/pp/gsqlparser/sqlpp/sqlformat.tpl">Online SQL Formatter</>a</li>
<li><a href="http://www.dbainfopower.com/dbaip_SQLreview.php">SQL Review</>a</li>
<li><a href="http://psti.equinoxbase.com/">Pl/Sql tidy</a></li>
<li><a href="http://vsbabu.org/software/lsqlb.html">Make your own with C</a></li>
<li>Use TOAD</li>
</ul>
<p>I decided that since SQLInform was mentioned a lot I would give it a try. I was suprised at how well it did. I gave it a huge amount of SQL to re-format and it gave it back to me formated. There is a limit on how much you can ask it to format at once but that shouldn&#039;t be a big issue. I didn&#039;t see that it choked on anything that I gave it and there were all kinds of nasty things going on in the SQL.</p>
<p>One interesting thing to come from this is that it seems there are no open source or truely free unix based formaters out there. It seems like it would be easy enough to get going since the SQL grammar is available for a number of different parser generators.</p>
<p>Tags: <a href="http://technorati.com/tag/SQL" rel="tag">SQL</a>, <a href="http://technorati.com/tag/TOAD" rel="tag"> TOAD</a>, <a href="http://technorati.com/tag/SQLInform" rel="tag"> SQLInform</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/database-administration/67/sql-beautifier/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Converting unix or java timestamps (time since the epoch) to real dates with Oracle</title>
		<link>http://www.ioncannon.net/database-administration/27/converting-unix-or-java-timestamps-time-since-the-epoch-to-real-dates-with-oracle/</link>
		<comments>http://www.ioncannon.net/database-administration/27/converting-unix-or-java-timestamps-time-since-the-epoch-to-real-dates-with-oracle/#comments</comments>
		<pubDate>Sat, 29 Apr 2006 22:12:17 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[database administration]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/uncategorized/27/converting-unix-or-java-timestamps-time-since-the-epoch-to-real-dates-with-oracle/</guid>
		<description><![CDATA[A few days ago I made use of a couple Oracle built in functions and it made me happy I didn&#039;t have to write a stored proc or some type of mini-app to do it. I needed to parse a timestamp out of a field that was put there by a java program. The timestamp [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I made use of a couple Oracle built in functions and it made me happy I didn&#039;t have to write a stored proc or some type of mini-app to do it. I needed to parse a timestamp out of a field that was put there by a java program. The timestamp was just the output of System.currentTimeInMillis()  and was concatenated onto some other information. </p>
<p>It took a little digging to find out how to convert a <a href="http://en.wikipedia.org/wiki/Unix_time">epoch</a> style timestamp but here it is:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">SELECT</span> new_time<span class="br0">&#40;</span> to_date<span class="br0">&#40;</span><span class="st0">&#039;01011970&#039;</span><span class="sy0">,</span> <span class="st0">&#039;ddmmyyyy&#039;</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">1</span><span class="sy0">/</span><span class="nu0">24</span><span class="sy0">/</span><span class="nu0">60</span><span class="sy0">/</span><span class="nu0">60</span> <span class="sy0">*</span> :currenttimeinmillis<span class="sy0">/</span><span class="nu0">1000</span><span class="sy0">,</span> <span class="st0">&#039;GMT&#039;</span><span class="sy0">,</span> <span class="st0">&#039;EDT&#039;</span> <span class="br0">&#41;</span> <span class="kw1">FROM</span> dual</div>
</div>
<p>Note that I convert the output from GMT to EDT here.
</p>
<p>Tags: <a href="http://technorati.com/tag/java" rel="tag">java</a>, <a href="http://technorati.com/tag/oracle" rel="tag"> oracle</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/database-administration/27/converting-unix-or-java-timestamps-time-since-the-epoch-to-real-dates-with-oracle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with Oracle Strings</title>
		<link>http://www.ioncannon.net/database-administration/51/fun-with-oracle-strings/</link>
		<comments>http://www.ioncannon.net/database-administration/51/fun-with-oracle-strings/#comments</comments>
		<pubDate>Tue, 14 Feb 2006 08:14:07 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[database administration]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/uncategorized/51/fun-with-oracle-strings/</guid>
		<description><![CDATA[Today I needed to find a way to count the number of unique email domains in a table. I figured there was a way of getting the index of a string in another string and sure enough there is. This did the trick in Oracle: The INSTR function gives you the location in a string [...]]]></description>
			<content:encoded><![CDATA[<p>Today I needed to find a way to count the number of unique email domains in a table. I figured there was a way of getting the index of a string in another string and sure enough there is. This did the trick in Oracle:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">SELECT</span> count<span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">,</span> SUBSTR<span class="br0">&#40;</span>email<span class="sy0">,</span> INSTR<span class="br0">&#40;</span>email<span class="sy0">,</span> <span class="st0">&#039;@&#039;</span><span class="sy0">,</span> 1<span class="sy0">,</span> 1<span class="br0">&#41;</span><span class="sy0">+</span>1<span class="br0">&#41;</span> <span class="kw1">FROM</span> SOMETABLE <span class="kw1">GROUP</span> <span class="kw1">BY</span> SUBSTR<span class="br0">&#40;</span>email<span class="sy0">,</span> INSTR<span class="br0">&#40;</span>email<span class="sy0">,</span> <span class="st0">&#039;@&#039;</span><span class="sy0">,</span> 1<span class="sy0">,</span> 1<span class="br0">&#41;</span><span class="sy0">+</span>1<span class="br0">&#41;</span> <span class="kw1">ORDER</span> <span class="kw1">BY</span> count<span class="br0">&#40;</span>1<span class="br0">&#41;</span> <span class="kw1">DESC</span></div>
</div>
<p>The INSTR function gives you the location in a string where another string is located. See the following link for more on the INSTR function: <a href="http://www.techonthenet.com/oracle/functions/instr.php">http://www.techonthenet.com/oracle/functions/instr.php</a></p>
<p>I&#039;ve always found the way Oracle handles case interesting. It looks like they are changing things a little starting with 10G: <a href="http://blogs.ittoolbox.com/database/solutions/archives/005951.asp">http://blogs.ittoolbox.com/database/solutions/archives/005951.asp</a>
</p>
<p>Tags: <a href="http://technorati.com/tag/oracle" rel="tag">oracle</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/database-administration/51/fun-with-oracle-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.193 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-02 17:33:24 -->

