<?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>SODEVE &#187; Database</title>
	<atom:link href="http://sodeve.net/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://sodeve.net</link>
	<description>a Software Developer(SODEVE)&#039;s blog recording his journey in pursuit of happyness.</description>
	<lastBuildDate>Sat, 04 Feb 2012 14:35:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>SQLPal: Amazingly Simple and Fast Oracle Query Tools</title>
		<link>http://sodeve.net/2011/06/sqlpal-amazingly-simple-and-fast-oracle-query-tools/</link>
		<comments>http://sodeve.net/2011/06/sqlpal-amazingly-simple-and-fast-oracle-query-tools/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 05:05:12 +0000</pubDate>
		<dc:creator>Hardono</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://sodeve.net/?p=990</guid>
		<description><![CDATA[In the past I have talked about using Tora to connect to Oracle. I also listed down downloads of Oracle Client for Windows. Today I am going to introduce you to SQLPal. &#160; Installation No installation needed! Just download the zip file and extract it at your convenience. You also need to have the latest JRE [...]
&nbsp;
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" href="http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Windows Oracle Clients Download" href="http://sodeve.net/2011/01/windows-oracle-clients-download/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="Windows Oracle Clients Download" width="100" height="75" />
 Windows Oracle Clients Download </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: RESOLVED" href="http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/homer_woohoo-150x150.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: RESOLVED" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: RESOLVED </a>
 
 </li>
 
  
</ul>


&nbsp;]]></description>
			<content:encoded><![CDATA[<p>In the past I have talked about using <a title="How to Connect TOra to Oracle Database" href="http://sodeve.net/2009/08/how-to-connect-tora-to-oracle-database/">Tora</a> to connect to Oracle. I also listed down downloads of <a title="Windows Oracle Clients Download" href="http://sodeve.net/2011/01/windows-oracle-clients-download/">Oracle Client</a> for Windows.</p>
<p>Today I am going to introduce you to <a title="SQLPal" href="http://www.pebblereports.com/sqlpal/">SQLPal</a>.<br />
&nbsp;</p>
<h3>Installation</h3>
<p>No installation needed! Just download the <a href="http://www.pebblereports.com/sqlpal/sqlpal.zip">zip file</a> and extract it at your convenience. You also need to have the latest <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">JRE</a> installed.</p>
<p><em><strong>Important:</strong></em> If you get an error when connecting to Oracle you need to update the JDBC driver included with SQLpal. Find classes12.jar in your Oracle installation and copy the file over to your SQLpal directory, replacing the existing file.</p>
<p>&nbsp;</p>
<h3>Setting Up Oracle Connection</h3>
<p><img src="http://sodeve.net/wp-content/uploads/2011/06/sqlpal.png" alt="" title="sqlpal" width="301" height="162" class="alignleft size-full wp-image-993" />Click the &#8216;power-plug&#8217; icon to initiate connection. It will ask you to provide:</p>
<ol>
<li>User ID</li>
<li>Password</li>
<li>Oracle&#8217;s server host name</li>
<li>Oracle&#8217;s server port number</li>
<li>Oracle&#8217;s server System ID (SID)</li>
</ol>
<p><img src="http://sodeve.net/wp-content/uploads/2011/06/sqlpal.2.png" alt="" title="sqlpal.2" width="438" height="347" class="aligncenter size-full wp-image-999" /></p>
<p>If you don&#8217;t know what is your Oracle server&#8217;s SID, connect to Oracle using your existing tools, and run the following query:</p>
<pre name="code" class="sql">

select instance from v$thread
</pre>
<p>SQLPal is very simple yet sufficient. It has only four tabs:</p>
<ol>
<li><strong>SQL Prompt</strong>. This tab is pretty much like SQL*Plus with steroid. You can:
<ol>
<li>run queries</li>
<li>use Up / Down key to retrieve previous queries </li>
<li>bookmark your queries (Bookmarks -> Bookmark last command &#8230;)</li>
<li>export query result to Excel (by pressing the Excel icon)</li>
</ol>
</li>
<li><strong>Scratchpad</strong>. This tab is just like any other query editor. You can:
<ol>
<li>load/save SQL file</li>
<li>save query result as HTML</li>
<li>export query result to Excel (by pressing the Excel icon)</li>
</ol>
</li>
<li><strong>Schema Browser</strong>. This tab will help you to see the details of every Oracle objects (Procedures, Packages, Functions, Tables, Views, Sequences, Synonims). Some objects are read-only (Tables, Views, Sequences, Synonims). But the rest are editable.</li>
<li><strong>Research</strong>. This tab is basically a browser pointing to resources that might help you when you hit a stumbling block.</li>
</ol>
<p>Try this tiny and efficient tools. I&#8217;m sure you going to like it very much!</p>
<p><strong>Credit:</strong>
<ol>
<li><a href="http://timewasteblog.com/2010/08/22/how-to-find-current-sid-of-oracle-from-sqlplus/">timewasteblog.com</a></li>
</ol>
<p>&nbsp;</p>
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" href="http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Windows Oracle Clients Download" href="http://sodeve.net/2011/01/windows-oracle-clients-download/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="Windows Oracle Clients Download" width="100" height="75" />
 Windows Oracle Clients Download </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: RESOLVED" href="http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/homer_woohoo-150x150.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: RESOLVED" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: RESOLVED </a>
 
 </li>
 
  
</ul>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/2011/06/sqlpal-amazingly-simple-and-fast-oracle-query-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Oracle Clients Download</title>
		<link>http://sodeve.net/2011/01/windows-oracle-clients-download/</link>
		<comments>http://sodeve.net/2011/01/windows-oracle-clients-download/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 16:20:00 +0000</pubDate>
		<dc:creator>Hardono</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://sodeve.net/?p=956</guid>
		<description><![CDATA[In case you&#8217;re looking for Windows Oracle Clients, here are the links: Oracle 11g Release 2 Client 32-bit 64-bit Oracle 11g Release 1 Client 32-bit 64-bit Oracle 10g Release 2 Client 32-bit 64-bit If you&#8217;re looking for Oracle Client v. 9 and below, sadly it&#8217;s no longer available publicly at Oracle website. You can still [...]
&nbsp;
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" href="http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: RESOLVED" href="http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/homer_woohoo-150x150.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: RESOLVED" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: RESOLVED </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to How to Connect TOra to Oracle Database" href="http://sodeve.net/2009/08/how-to-connect-tora-to-oracle-database/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/Tora_largelogo-150x150.gif&h=75&w=100&q=95" alt="How to Connect TOra to Oracle Database" width="100" height="75" />
 How to Connect TOra to Oracle Database </a>
 
 </li>
 
  
</ul>


&nbsp;]]></description>
			<content:encoded><![CDATA[<p>In case you&#8217;re looking for Windows Oracle Clients, here are the links:</p>
<ol>
<li>Oracle 11g Release 2 Client <a target="_blank" href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win32soft-098987.html">32-bit</a> <a href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html">64-bit</a></li>
<li>Oracle 11g Release 1 Client <a target="_blank" href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/111060-win32soft-099267.html">32-bit</a> <a arget="_blank" href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/111060-win64soft-099656.html">64-bit</a></li>
<li>Oracle 10g Release 2 Client <a target="_blank" href="http://www.oracle.com/technetwork/database/10201winsoft-095341.html">32-bit</a> <a target="_blank" href="http://www.oracle.com/technetwork/database/10201winx64soft-090882.html">64-bit</a></li>
</ol>
<p>If  you&#8217;re looking for Oracle Client v. 9 and below, sadly it&#8217;s no longer available publicly at Oracle website. You can still call their sales rep and request for quotation though.</p>
<p>&nbsp;</p>
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" href="http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: RESOLVED" href="http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/homer_woohoo-150x150.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: RESOLVED" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: RESOLVED </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to How to Connect TOra to Oracle Database" href="http://sodeve.net/2009/08/how-to-connect-tora-to-oracle-database/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/Tora_largelogo-150x150.gif&h=75&w=100&q=95" alt="How to Connect TOra to Oracle Database" width="100" height="75" />
 How to Connect TOra to Oracle Database </a>
 
 </li>
 
  
</ul>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/2011/01/windows-oracle-clients-download/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Execute Oracle Function From NHibernate</title>
		<link>http://sodeve.net/2010/04/how-to-execute-oracle-function-from-nhibernate/</link>
		<comments>http://sodeve.net/2010/04/how-to-execute-oracle-function-from-nhibernate/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 19:22:34 +0000</pubDate>
		<dc:creator>Hardono</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://sodeve.net/?p=904</guid>
		<description><![CDATA[I am currently doing a project utilizing NHibernate to connect to a legacy Oracle DB. Everything was nice and easy until I hit this problem. I need to retrieve a particular information, but to do this I must connect a number of tables. This means I need to create more persistent classes, more mapping files, [...]
&nbsp;
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to How to Connect TOra to Oracle Database" href="http://sodeve.net/2009/08/how-to-connect-tora-to-oracle-database/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/Tora_largelogo-150x150.gif&h=75&w=100&q=95" alt="How to Connect TOra to Oracle Database" width="100" height="75" />
 How to Connect TOra to Oracle Database </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" href="http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: RESOLVED" href="http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/homer_woohoo-150x150.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: RESOLVED" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: RESOLVED </a>
 
 </li>
 
  
</ul>


&nbsp;]]></description>
			<content:encoded><![CDATA[<p>I am currently doing a project utilizing NHibernate to connect to a legacy Oracle DB. Everything was nice and easy until I hit this problem. I need to retrieve a particular information, but to do this I must connect a number of tables. This means I need to create more persistent classes, more mapping files, which is sucks because I can actually just execute a stored function and get what I need.<br />
<a href="http://sodeve.net/2010/04/how-to-execute-oracle-function-from-nhibernate/" title="How To Execute Oracle Function From NHibernate"><img alt="Nhibernate" src="http://sodeve.net/wp-content/uploads/2010/04/nhib-logo04.gif" title="Nhibernate" class="aligncenter" width="300" height="166" /></a></p>
<p>So after scratching my head for quite sometimes, I found out that the solution was quite simple.</p>
<pre name="code" class="vb">
Using sessFact As ISessionFactory = CreateSessionFactory()
   Using sess As ISession = sessFact.OpenSession()
      Using transact As ITransaction = sess.BeginTransaction()
         '....
         Dim con As IDbConnection = sess.Connection
         Dim cmd As IDbCommand = con.CreateCommand()
         sess.Transaction.Enlist(cmd)
         cmd.CommandText = "select MyPackageName.MyFunction(" &#038; myFunctionParam &#038; ") from dual"
         dim objResult as Objetc = cmd.ExecuteScalar()
         '.....
      End Using
   End Using
End Using
</pre>
<p>I know this is not the right way, but I need to make compromise considering that this is a legacy database.</p>
<p>&nbsp;</p>
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to How to Connect TOra to Oracle Database" href="http://sodeve.net/2009/08/how-to-connect-tora-to-oracle-database/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/Tora_largelogo-150x150.gif&h=75&w=100&q=95" alt="How to Connect TOra to Oracle Database" width="100" height="75" />
 How to Connect TOra to Oracle Database </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" href="http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: RESOLVED" href="http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/homer_woohoo-150x150.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: RESOLVED" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: RESOLVED </a>
 
 </li>
 
  
</ul>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/2010/04/how-to-execute-oracle-function-from-nhibernate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Connect TOra to Oracle Database</title>
		<link>http://sodeve.net/2009/08/how-to-connect-tora-to-oracle-database/</link>
		<comments>http://sodeve.net/2009/08/how-to-connect-tora-to-oracle-database/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 16:28:22 +0000</pubDate>
		<dc:creator>Hardono</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://sodeve.net/?p=763</guid>
		<description><![CDATA[A few months ago my colleague asked me to try out TOra (Toolkit for Oracle). I downloaded the latest stable version of TOra (2.0), and get it installed in my PC. But somehow I could&#8217;t get it to connect to our Oracle test DB. I tried all combinations of the connection settings, but I always [...]
&nbsp;
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" href="http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: RESOLVED" href="http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/homer_woohoo-150x150.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: RESOLVED" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: RESOLVED </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Traversing Database Server using SQL SMO" href="http://sodeve.net/2007/07/traversing-database-server-using-sql-smo/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="Traversing Database Server using SQL SMO" width="100" height="75" />
 Traversing Database Server using SQL SMO </a>
 
 </li>
 
  
</ul>


&nbsp;]]></description>
			<content:encoded><![CDATA[<p>A few months ago my colleague asked me to try out <a href="http://tora.sourceforge.net/" target = "_blank">TOra (Toolkit for Oracle)</a>. I <a href="http://sourceforge.net/projects/tora/files/tora/2.0.0/TOra-2.0-setup.exe/download" target = "_blank">downloaded</a> the latest stable version of TOra (2.0), and get it installed in my PC.</p>
<p>But somehow I could&#8217;t get it to connect to our Oracle test DB. I tried all combinations of the connection settings, but I always get either of these error messages whenever I press the connect button:</p>
<ul>
<li>ORA-06401: NETCMN: Invalid driver designator</li>
<li>ORA-12560: TNS: protocol adapter error</li>
</ul>
<p>Desperate for guidance, I lurked at TOra&#8217;s community forum looking for one. I found a number of questions from people who apparently have the same problem as mine. I tried the tips given there, but I still unable to get TOra connected. </p>
<p>I stopped my experiment with TOra because my colleague suggested us to settle with Oracle&#8217;s <a href="http://www.oracle.com/technology/products/database/sql_developer" target="_blank">SQL Developer</a> instead. I noticed that SQL Developer is a Java-based Windows application, so I already anticipated that it is going to be much slower than native Windows application.</p>
<div style="float: left; margin-right: 15px; margin-bottom: 15px;"><center><a href="http://sodeve.net/how-to-connect-tora-to-oracle-database"><img src="http://sodeve.net/wp-content/uploads/2009/08/Tora_largelogo.gif" alt="TOra (Toolkit for Oracle)"/></a></center></div>
<p>So after months of occasionally frustrated by SQL Developer&#8217;s slowness and memory-hogging, I return back to trying to get TOra connected. Hoping that my fortune is improved this time. And it does improved <img src='http://sodeve.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>I installed TOra (the latest stable version is still 2.0) and then visited TOra&#8217;s community forum for clues. Then I found out someone mentioned that TOra 2.0 was build based on Oracle Instant Client 10. Hmm.. I am still using Oracle 9.2 Instant Client. This could be the main cause why TOra unable to connect.</p>
<p>So I <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html" target="_blank">downloaded</a> Oracle&#8217;s Instant Client v. 10.2 and extracted its content to my TOra installation folder. Then I tried the following settings:</p>
<p><a href="http://sodeve.net/2009/08/how-to-connect-tora-to-oracle-database"><img src="http://sodeve.net/wp-content/uploads/2009/08/Tora-Settings.png" alt="" title="Tora Settings" width="668" height="579" class="aligncenter size-full wp-image-1263" /></a></p>
<p>&nbsp;</p>
<h3>Voila!!! It works!!!</h3>
<p>&nbsp;</p>
<h3>Update:</h3>
<p><del datetime="2009-08-07T01:04:55+00:00">Unfortunately, I am still unable to use TNS record to get TOra connected. I&#8217;ll update again once I have success getting TOra connected using TNS records.</del></p>
<p>To make TOra able to use TNS, please set the following Environment Variables:</p>
<ul>
<li><strong>TNS_ADMIN</strong>. Value: fullpath of TNSNames.ORA&#8217;s directory</li>
<li><strong>ORACLE_HOME</strong>. Value: fullpath of Oracle&#8217;s installation directory</li>
</ul>
<p>Once you&#8217;ve done above steps, a new connection provider [<strong>Oracle (TNS)</strong>] will be available. </p>
<p>&nbsp;</p>
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" href="http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: RESOLVED" href="http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/homer_woohoo-150x150.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: RESOLVED" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: RESOLVED </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Traversing Database Server using SQL SMO" href="http://sodeve.net/2007/07/traversing-database-server-using-sql-smo/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="Traversing Database Server using SQL SMO" width="100" height="75" />
 Traversing Database Server using SQL SMO </a>
 
 </li>
 
  
</ul>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/2009/08/how-to-connect-tora-to-oracle-database/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Oracle + IIS + ASP.NET Problem: RESOLVED</title>
		<link>http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/</link>
		<comments>http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 03:08:40 +0000</pubDate>
		<dc:creator>Hardono</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://sodeve.net/oracle-iis-asp-net-problem-resolved/</guid>
		<description><![CDATA[<div style="float: left; margin-right: 15px; margin-bottom: 15px;"><center><a href="http://sodeve.net/Oracle-IIS-ASP-NET-Problem-RESOLVED"><img alt="Woohoo" src="http://i154.photobucket.com/albums/s242/sodeve/homer_woohoo.jpg"/></a></center></div>Earlier today, I blogged about <a href="http://sodeve.net/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/">the connection problem between IIS and Oracle</a>. I finally found the answer. The problem is actually very simple, it is related to NTFS File permission.
<p>&#160;</p>
All this time I thought that when you give a user permission to a parent folder, the permission will automatically inherited by the child folders and files (if you click the Advanced button in Folder's Properties - Security tab, the "<em>Inherit from parent the permission entries that apply to child objects. ....</em>" is checked by default).
<p>&#160;</p>
So I did add full-control permission to the Oracle Home folder for the IIS Anonymous User account as recommended by <a href="http://support.microsoft.com/kb/255084">Microsoft Knowledge Base</a>. But it didn't help.
<p>&#160;</p>
After trying to use the Oracle OLE DB Provider (provided by Oracle, previously using the one provided by Microsoft), I encountered a new error message. I googled for it, and I found that I must <strong>REPLACE </strong>the child objects' NTFS security permission in the Oracle Home Folder to make the parent's folder NTFS security permission transcended to the child objects.
<p>&#160;</p>
So remember, after added the IIS Anonymous User (<em>IUSR_...</em>) to Oracle Home's folder, we need to force the permission to apply to its child folders and files. Hopefully the following screenshots will help.
<p>&#160;</p>
<img src='http://sodeve.net/wp-content/uploads/2009/04/ntfs-permission.png' alt='Folder - Properties - Security - Advanced' />
&nbsp;
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" href="http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to How to Install DotNetNuke" href="http://sodeve.net/2007/03/how-to-install-dotnetnuke/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/iis-150x150.png&h=75&w=100&q=95" alt="How to Install DotNetNuke" width="100" height="75" />
 How to Install DotNetNuke </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Traversing Database Server using SQL SMO" href="http://sodeve.net/2007/07/traversing-database-server-using-sql-smo/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="Traversing Database Server using SQL SMO" width="100" height="75" />
 Traversing Database Server using SQL SMO </a>
 
 </li>
 
  
</ul>


&nbsp;]]></description>
			<content:encoded><![CDATA[<div style="float: left; margin-right: 15px; margin-bottom: 15px;"><center><a href="http://sodeve.net/Oracle-IIS-ASP-NET-Problem-RESOLVED"><img alt="Woohoo" src="http://i154.photobucket.com/albums/s242/sodeve/homer_woohoo.jpg"/></a></center></div>
<p>Earlier today, I blogged about <a href="http://sodeve.net/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/">the connection problem between IIS and Oracle</a>. I finally found the answer. The problem is actually very simple, it is related to NTFS File permission. </p>
<p>All this time I thought that when you give a user permission to a parent folder, the permission will automatically inherited by the child folders and files (if you click the Advanced button in Folder&#8217;s Properties &#8211; Security tab, the &#8220;<em>Inherit from parent the permission entries that apply to child objects. &#8230;.</em>&#8221; is checked by default).</p>
<p>So I did add full-control permission to the Oracle Home folder for the IIS Anonymous User account as recommended by <a href="http://support.microsoft.com/kb/255084">Microsoft Knowledge Base</a>. But it didn&#8217;t help.</p>
<p>After trying to use the Oracle OLE DB Provider (provided by Oracle, previously using the one provided by Microsoft), I encountered a new error message. I googled for it, and I found that I must <strong>REPLACE </strong>the child objects&#8217; NTFS security permission in the Oracle Home Folder to make the parent&#8217;s folder NTFS security permission transcended to the child objects.</p>
<p>So remember, after added the IIS Anonymous User (<em>IUSR_&#8230;</em>) to Oracle Home&#8217;s folder, we need to force the permission to apply to its child folders and files. Hopefully the following screenshots will help.</p>
<p><img src='http://sodeve.net/wp-content/uploads/2009/04/ntfs-permission.png' alt='Folder - Properties - Security - Advanced' /></p>
<p>&nbsp;</p>
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" href="http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found" width="100" height="75" />
 Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to How to Install DotNetNuke" href="http://sodeve.net/2007/03/how-to-install-dotnetnuke/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/iis-150x150.png&h=75&w=100&q=95" alt="How to Install DotNetNuke" width="100" height="75" />
 How to Install DotNetNuke </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Traversing Database Server using SQL SMO" href="http://sodeve.net/2007/07/traversing-database-server-using-sql-smo/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="Traversing Database Server using SQL SMO" width="100" height="75" />
 Traversing Database Server using SQL SMO </a>
 
 </li>
 
  
</ul>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/2009/04/oracle-iis-asp-net-problem-resolved/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found</title>
		<link>http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/</link>
		<comments>http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 16:56:51 +0000</pubDate>
		<dc:creator>Hardono</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://sodeve.net/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/</guid>
		<description><![CDATA[I have deployed my CPAMS application to the production server. To my dismay, I encountered this error message: 

<blockquote><strong>"Oracle client and networking components were not found. These components  are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation.<br/><br/>
Provider is unable to function until these components are installed.</strong></blockquote>

So far I have used these resources to resolve this problem:
<ol>
	<li><a href="http://support.microsoft.com/kb/255084">How To Troubleshoot an ASP-to-Oracle Connectivity Problem</a></li>
	<li><a href="http://forums.oracle.com/forums/thread.jspa?messageID=2119096">OTN Discussion Forums : Oracle client and networking components</a></li>
	<li><a href="http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic29102.aspx">System.Data.OracleClient requires Oracle client software version 8.1.7 or greater</a></li>
</ol>

None of them able to resolve the issue. I'll update more on this issue later on.
&nbsp;
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to ASP.NET UI Testing With Selenium" href="http://sodeve.net/2008/09/asp_net_ui_testing_with_selenium/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/selenium-ide-150x150.gif&h=75&w=100&q=95" alt="ASP.NET UI Testing With Selenium" width="100" height="75" />
 ASP.NET UI Testing With Selenium </a>
 
 </li>
 
  
</ul>


&nbsp;]]></description>
			<content:encoded><![CDATA[<p>I have deployed my CPAMS application to the production server. To my dismay, I encountered this error message: </p>
<blockquote><p><strong>&#8220;Oracle client and networking components were not found. These components  are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation.<br/><br/><br />
Provider is unable to function until these components are installed.</strong></p></blockquote>
<p>So far I have used these resources to resolve this problem:</p>
<ol>
<li><a href="http://support.microsoft.com/kb/255084">How To Troubleshoot an ASP-to-Oracle Connectivity Problem</a></li>
<li><a href="http://forums.oracle.com/forums/thread.jspa?messageID=2119096">OTN Discussion Forums : Oracle client and networking components</a></li>
<li><a href="http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic29102.aspx">System.Data.OracleClient requires Oracle client software version 8.1.7 or greater</a></li>
</ol>
<p>None of them able to resolve the issue. I&#8217;ll update more on this issue later on.</p>
<p>&nbsp;</p>
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to ASP.NET UI Testing With Selenium" href="http://sodeve.net/2008/09/asp_net_ui_testing_with_selenium/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/selenium-ide-150x150.gif&h=75&w=100&q=95" alt="ASP.NET UI Testing With Selenium" width="100" height="75" />
 ASP.NET UI Testing With Selenium </a>
 
 </li>
 
  
</ul>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/2009/04/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL String Formatter (Part 2)</title>
		<link>http://sodeve.net/2007/08/sql-string-formatter-part-2/</link>
		<comments>http://sodeve.net/2007/08/sql-string-formatter-part-2/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 16:58:13 +0000</pubDate>
		<dc:creator>Hardono</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://sodeve.net/sql-string-formatter-part-2/</guid>
		<description><![CDATA[As I promised before, I will put the output of the programs that I mention in the <a href="http://sodeve.net/sql-string-formatter-part-1/">previous post</a>.
<p> </p>
As input I will use the following SQL string (which I have verified that it is a valid SQL statement).
<div class="codediv"><div class="codeclicker"> </div>
<pre lang="sql">
 ALTER PROCEDURE [dbo].[aspnet_Setup_RemoveAllRoleMembers] @name   sysname AS BEGIN     CREATE TABLE #aspnet_RoleMembers     (         Group_name      sysname,         Group_id        smallint,         Users_in_group  sysname,        User_id         smallint     );     INSERT INTO #aspnet_RoleMembers     EXEC sp_helpuser @name;     DECLARE @user_id smallint;    DECLARE @cmd nvarchar(500);    DECLARE c1 cursor FORWARD_ONLY FOR         SELECT User_id FROM #aspnet_RoleMembers;    OPEN c1;    FETCH c1 INTO @user_id;    WHILE (@@fetch_status = 0)    BEGIN        SET @cmd = 'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';        EXEC (@cmd);        FETCH c1 INTO @user_id      END;     CLOSE c1;    DEALLOCATE c1  END
</pre>
</div>
<p> </p>
The output of the program are as follows:
<ol>
	<li><a href="http://www.sqlinform.com/">SQLinForm</a><br/><div class="codediv"><div class="codeclicker"> </div>
<pre lang="sql">
ALTER
PROCEDURE [dbo].[aspnet_Setup_RemoveAllRoleMembers] @name sysname
AS
        BEGIN
                CREATE TABLE #aspnet_RoleMembers
                                (
                                Group_name sysname    ,
                                Group_id smallint     ,
                                Users_in_group sysname,
                                User_id smallint
                                );
                INSERT INTO #aspnet_RoleMembers EXEC sp_helpuser @name;
                DECLARE @user_id smallint;
                DECLARE @cmd nvarchar(500);
                DECLARE c1
                cursor FORWARD_ONLY FOR
                        SELECT User_id FROM #aspnet_RoleMembers;
                        OPEN c1;
                        FETCH c1 INTO @user_id;
                WHILE (@@fetch_status = 0)
                BEGIN
                        SET @cmd =  'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';
                        EXEC (@cmd);
                        FETCH c1 INTO @user_id
                END;
                CLOSE c1;
                DEALLOCATE c1
        END
</pre>
</div><br/>
Initially I thought there was missing 'END', but I found out that because I choose 'Any SQL' instead of 'SQL Server'. Very impressive!!!
</li>	<li><a href="http://www.wangz.net/cgi-bin/pp/gsqlparser/sqlpp/sqlformat.tpl">SQL Online Formatter</a><br/><div class="codediv"><div class="codeclicker"> </div>
<pre lang="sql">
/* Powered by General SQL Parser (www.sqlparser.com) */

ALTER PROCEDURE [DBO].[ASPNET_SETUP_REMOVEALLROLEMEMBERS]
               @name SYSNAME
AS
  BEGIN
    CREATE TABLE #ASPNET_ROLEMEMBERS (
      GROUP_NAME     SYSNAME,
      GROUP_ID       SMALLINT,
      USERS_IN_GROUP SYSNAME,
      USER_ID        SMALLINT);
    
    INSERT INTO #ASPNET_ROLEMEMBERS
    EXEC SP_HELPUSER
       @name;
    
    DECLARE  @user_id SMALLINT;
    
    DECLARE  @cmd NVARCHAR(500);
    
    DECLARE C1 CURSOR FORWARD_ONLY FOR
    SELECT USER_ID
    FROM   #ASPNET_ROLEMEMBERS;
    
    OPEN C1;
    
    FETCH  C1
    INTO @user_id;
    
    WHILE (@@FETCH_STATUS = 0)
      BEGIN
        SET @cmd = 'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';
        
        EXEC( @cmd);
        
        FETCH  C1
        INTO @user_id
      END;
    
    CLOSE C1;
    
    DEALLOCATE C1
  END

</pre>
</div><br />
As you see, it also performs as good as SQLinForm</li>
	<li>SQL Review<br/><div class="codediv"><div class="codeclicker"> </div>
<pre lang="sql">
ALTER PROCEDURE [dbo].[aspnet_Setup_RemoveAllRoleMembers] @name sysname AS 
BEGIN
   
CREATE TABLE #aspnet_RoleMembers (
      Group_name sysname,
      Group_id smallint,
      Users_in_group sysname,
      User_id smallint 
   );
   
INSERT INTO #aspnet_RoleMembers 
EXEC sp_helpuser @name;
   
DECLARE
   @user_id smallint;
   
DECLARE
   @cmd nvarchar(500);
   
DECLARE
   c1 
CURSOR FORWARD_ONLY 
FOR 
SELECT
   User_id 
FROM
   #aspnet_RoleMembers;
   OPEN c1;
   FETCH c1 INTO @user_id;
   WHILE (@@fetch_status = 0) 
BEGIN
   
SET @cmd = 'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';
   
EXEC (@cmd);
   FETCH c1 INTO @user_id 
END;
CLOSE c1;
DEALLOCATE c1 
END
</pre>
</div><br/>Unfortunately there is no option to indent text between BEGIN and END. But the plus point is you can run it </li>	
<li><a href="http://psti.equinoxbase.com/index.html">Pl/sql tidy</a><br/>Hmm.. doesn't seem to work. Is it because it only parse PL/SQL? (I will investigate further when I really have nothing to do :P)</li>
</ol>


As for the LEX script, I'm still trying to get it work on C# using <a href="http://www.cybercom.net/~zbrad/DotNet/Lex/Lex.htm">CsLEX</a>, so it would take sometime before I post the result here.
&nbsp;
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to SQL String Formatter (Part 1)" href="http://sodeve.net/2007/08/sql-string-formatter-part-1/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="SQL String Formatter (Part 1)" width="100" height="75" />
 SQL String Formatter (Part 1) </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to MS SQL version of MySQL&#8217;s Group_Concat" href="http://sodeve.net/2006/01/ms-sql-version-of-mysqls-group_concat/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="MS SQL version of MySQL&#8217;s Group_Concat" width="100" height="75" />
 MS SQL version of MySQL&#8217;s Group_Concat </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to MS-SQL Stored Procedure for Absolute Beginner, Part 1" href="http://sodeve.net/2007/03/ms-sql-stored-procedure-for-absolute-beginner-part-1/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish3.jpg&h=75&w=100&q=95" alt="MS-SQL Stored Procedure for Absolute Beginner, Part 1" width="100" height="75" />
 MS-SQL Stored Procedure for Absolute Beginner, Part 1 </a>
 
 </li>
 
  
</ul>


&nbsp;]]></description>
			<content:encoded><![CDATA[<p><a href="http://sodeve.net/2007/08/sql-string-formatter-part-2/sql-server-logo/" rel="attachment wp-att-2117"><img src="http://sodeve.net/wp-content/uploads/2007/08/sql.server.logo_.png" alt="" title="sql.server.logo" width="300" height="241" class="aligncenter size-full wp-image-2117" /></a>As I promised before, I will put the output of the programs that I mention in the <a href="http://sodeve.net/sql-string-formatter-part-1/">previous post</a>.</p>
<p>As input I will use the following SQL string (which I have verified that it is a valid SQL statement).</p>
<pre name="code" class="sql">
 ALTER PROCEDURE [dbo].[aspnet_Setup_RemoveAllRoleMembers] @name   sysname AS BEGIN     CREATE TABLE #aspnet_RoleMembers     (         Group_name      sysname,         Group_id        smallint,         Users_in_group  sysname,        User_id         smallint     );     INSERT INTO #aspnet_RoleMembers     EXEC sp_helpuser @name;     DECLARE @user_id smallint;    DECLARE @cmd nvarchar(500);    DECLARE c1 cursor FORWARD_ONLY FOR         SELECT User_id FROM #aspnet_RoleMembers;    OPEN c1;    FETCH c1 INTO @user_id;    WHILE (@@fetch_status = 0)    BEGIN        SET @cmd = 'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';        EXEC (@cmd);        FETCH c1 INTO @user_id      END;     CLOSE c1;    DEALLOCATE c1  END
</pre>
</p>
<p>The output of the program are as follows:</p>
<ol>
<li><a href="http://www.sqlinform.com/">SQLinForm</a><br/>
<pre name="code" class="sql">
ALTER
PROCEDURE [dbo].[aspnet_Setup_RemoveAllRoleMembers] @name sysname
AS
        BEGIN
                CREATE TABLE #aspnet_RoleMembers
                                (
                                Group_name sysname    ,
                                Group_id smallint     ,
                                Users_in_group sysname,
                                User_id smallint
                                );
                INSERT INTO #aspnet_RoleMembers EXEC sp_helpuser @name;
                DECLARE @user_id smallint;
                DECLARE @cmd nvarchar(500);
                DECLARE c1
                cursor FORWARD_ONLY FOR
                        SELECT User_id FROM #aspnet_RoleMembers;
                        OPEN c1;
                        FETCH c1 INTO @user_id;
                WHILE (@@fetch_status = 0)
                BEGIN
                        SET @cmd =  'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';
                        EXEC (@cmd);
                        FETCH c1 INTO @user_id
                END;
                CLOSE c1;
                DEALLOCATE c1
        END
</pre>
<p><br/><br />
Initially I thought there was missing &#8216;END&#8217;, but I found out that because I choose &#8216;Any SQL&#8217; instead of &#8216;SQL Server&#8217;. Very impressive!!!
</li>
<li><a href="http://www.wangz.net/cgi-bin/pp/gsqlparser/sqlpp/sqlformat.tpl">SQL Online Formatter</a><br/>
<pre name="code" class="sql">
ALTER PROCEDURE [DBO].[ASPNET_SETUP_REMOVEALLROLEMEMBERS]
               @name SYSNAME
AS
  BEGIN
    CREATE TABLE #ASPNET_ROLEMEMBERS (
      GROUP_NAME     SYSNAME,
      GROUP_ID       SMALLINT,
      USERS_IN_GROUP SYSNAME,
      USER_ID        SMALLINT);

    INSERT INTO #ASPNET_ROLEMEMBERS
    EXEC SP_HELPUSER
       @name;

    DECLARE  @user_id SMALLINT;

    DECLARE  @cmd NVARCHAR(500);

    DECLARE C1 CURSOR FORWARD_ONLY FOR
    SELECT USER_ID
    FROM   #ASPNET_ROLEMEMBERS;

    OPEN C1;

    FETCH  C1
    INTO @user_id;

    WHILE (@@FETCH_STATUS = 0)
      BEGIN
        SET @cmd = 'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';

        EXEC( @cmd);

        FETCH  C1
        INTO @user_id
      END;

    CLOSE C1;

    DEALLOCATE C1
  END
</pre>
<p>
As you see, it also performs as good as SQLinForm</li>
<li>SQL Review<br/>
<pre name="code" class="sql">
ALTER PROCEDURE [dbo].[aspnet_Setup_RemoveAllRoleMembers] @name sysname AS
BEGIN

CREATE TABLE #aspnet_RoleMembers (
      Group_name sysname,
      Group_id smallint,
      Users_in_group sysname,
      User_id smallint
   );

INSERT INTO #aspnet_RoleMembers
EXEC sp_helpuser @name;

DECLARE
   @user_id smallint;

DECLARE
   @cmd nvarchar(500);

DECLARE
   c1
CURSOR FORWARD_ONLY
FOR
SELECT
   User_id
FROM
   #aspnet_RoleMembers;
   OPEN c1;
   FETCH c1 INTO @user_id;
   WHILE (@@fetch_status = 0)
BEGIN

SET @cmd = 'EXEC sp_droprolemember ' + '''' + @name + ''', ''' + USER_NAME(@user_id) + '''';

EXEC (@cmd);
   FETCH c1 INTO @user_id
END;
CLOSE c1;
DEALLOCATE c1
END
</pre>
<p><br/>Unfortunately there is no option to indent text between BEGIN and END. But the plus point is you can run it </li>
<li><a href="http://psti.equinoxbase.com/index.html">Pl/sql tidy</a><br/>Hmm.. doesn&#8217;t seem to work. Is it because it only parse PL/SQL? (I will investigate further when I really have nothing to do <img src='http://sodeve.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> )</li>
</ol>
<p>As for the LEX script, I&#8217;m still trying to get it work on C# using <a href="http://www.cybercom.net/~zbrad/DotNet/Lex/Lex.htm">CsLEX</a>, so it would take sometime before I post the result here.</p>
<p>&nbsp;</p>
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to SQL String Formatter (Part 1)" href="http://sodeve.net/2007/08/sql-string-formatter-part-1/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="SQL String Formatter (Part 1)" width="100" height="75" />
 SQL String Formatter (Part 1) </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to MS SQL version of MySQL&#8217;s Group_Concat" href="http://sodeve.net/2006/01/ms-sql-version-of-mysqls-group_concat/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="MS SQL version of MySQL&#8217;s Group_Concat" width="100" height="75" />
 MS SQL version of MySQL&#8217;s Group_Concat </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to MS-SQL Stored Procedure for Absolute Beginner, Part 1" href="http://sodeve.net/2007/03/ms-sql-stored-procedure-for-absolute-beginner-part-1/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish3.jpg&h=75&w=100&q=95" alt="MS-SQL Stored Procedure for Absolute Beginner, Part 1" width="100" height="75" />
 MS-SQL Stored Procedure for Absolute Beginner, Part 1 </a>
 
 </li>
 
  
</ul>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/2007/08/sql-string-formatter-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL String Formatter (Part 1)</title>
		<link>http://sodeve.net/2007/08/sql-string-formatter-part-1/</link>
		<comments>http://sodeve.net/2007/08/sql-string-formatter-part-1/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 16:44:55 +0000</pubDate>
		<dc:creator>Hardono</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://sodeve.net/sql-string-formatter-part-1/</guid>
		<description><![CDATA[I am looking for a code (or command line software) that able to format/tidy-up SQL string to make it readable and doesn&#8217;t irritate the eyes. So far I have found: SQLinFormIt&#8217;s quite handy, you can run it on your browser and download the offline version which is packaged into one single Java Jar file. Unfortunately, [...]
&nbsp;
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to MS-SQL Stored Procedure for Absolute Beginner, Part 1" href="http://sodeve.net/2007/03/ms-sql-stored-procedure-for-absolute-beginner-part-1/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="MS-SQL Stored Procedure for Absolute Beginner, Part 1" width="100" height="75" />
 MS-SQL Stored Procedure for Absolute Beginner, Part 1 </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Reading CSV File with .NET" href="http://sodeve.net/2007/04/reading-csv-file-with-net/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="Reading CSV File with .NET" width="100" height="75" />
 Reading CSV File with .NET </a>
 
 </li>
 
  
</ul>


&nbsp;]]></description>
			<content:encoded><![CDATA[<p>I am looking for a code (or command line software) that able to format/tidy-up SQL string to make it readable and doesn&#8217;t irritate the eyes. So far I have found:</p>
<ol>
<li><a href="http://www.sqlinform.com/">SQLinForm</a><br />It&#8217;s quite handy, you can run it on your browser and download the offline version which is packaged into one single Java Jar file. Unfortunately, I&#8217;m looking for something with with command line or open source. At least with command line support I can invoke it from my .NET program to process the temporary file.</li>
<li><a href="http://www.wangz.net/cgi-bin/pp/gsqlparser/sqlpp/sqlformat.tpl">SQL Online Formatter</a><br /> Still without the programmability support.</li>
<li><a href="http://www.dbainfopower.com/dbaip_SQLreview.php">SQL Review</a><br/>With command line support. Unfortunately It&#8217;s throwing error on one of my stored procedure, but it still gives you the output.</li>
<li><a href="http://psti.equinoxbase.com/">Pl/Sql Tidy</a><br /> This program is only available in command line. Unfortunately, it never able to process my stored procedure. I not so sure whether it&#8217;s still maintained.</li>
<li>Using <a href="http://vsbabu.org/software/lsqlb.html">Flex Script.</a><br />This page is pure inspirational. It immediately opened up my eyes for the possibility of using Flex or Regular Expression. I think will stick to this solution.</li>
</ol>
<p>Although I have made up my mind, I will provide the output of each program in the next posting. Hopefully once I am be able to port VS. Babu&#8217;s lex script (or make my own regular expression code), I will share it with you all.</p>
<p>Credits:</p>
<blockquote><p>1. <a href="http://www.ioncannon.net/oracle/67/sql-beautifier/">Carson McDonald</a></p></blockquote>
<p>&nbsp;</p>
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to MS-SQL Stored Procedure for Absolute Beginner, Part 1" href="http://sodeve.net/2007/03/ms-sql-stored-procedure-for-absolute-beginner-part-1/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="MS-SQL Stored Procedure for Absolute Beginner, Part 1" width="100" height="75" />
 MS-SQL Stored Procedure for Absolute Beginner, Part 1 </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Reading CSV File with .NET" href="http://sodeve.net/2007/04/reading-csv-file-with-net/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="Reading CSV File with .NET" width="100" height="75" />
 Reading CSV File with .NET </a>
 
 </li>
 
  
</ul>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/2007/08/sql-string-formatter-part-1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Traversing Database Server using SQL SMO</title>
		<link>http://sodeve.net/2007/07/traversing-database-server-using-sql-smo/</link>
		<comments>http://sodeve.net/2007/07/traversing-database-server-using-sql-smo/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 11:31:37 +0000</pubDate>
		<dc:creator>Hardono</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://sodeve.net/traversing-database-server-using-sql-smo/</guid>
		<description><![CDATA[SQL SMO (SQL Management Object) is a collection of assemblies that shipped together with SQL 2005. This collection of assemblies is all that you need to control your SQL Server. Be it SQL 2005, or SQL 2000, you can control/manipulate it programmatically using SQL SMO.
<p>&#160;</p>
Since SQL SMO gave you the ability to treat the database elements such as Table, Database, Stored Procedure, and Trigger as an object, interacting with them should be relatively easy and practical. Additionally, you might want to check out this list of things that make <a href="http://suburbandestiny.com/tech/?p=159">SQL SMO exciting</a>.
<p>&#160;</p>
OK, lets get our hand dirty with the project. The first step would be importing the references into your project. If you use Visual Studio 2005, look for Microsoft.SqlServer.Smo in the list of .NET assembly when you open 'Add References' window. 
If you already have MS SQL 2005 installed, you can find the DLLs in the SDKAssemblies folder of your MS SQL 2005 installation folder.
If you don't have MS SQL 2005 installed in your computer, you might want to download the Express edition <a href="http://www.microsoft.com/downloads/details.aspx?familyid=220549B5-0B07-4448-8848-DCC397514B41&#038;displaylang=en">HERE</a>. 
<p>&#160;</p>
Next, you could use the following code as reference.
&nbsp;
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to Storm is coming" href="http://sodeve.net/2006/04/storm-is-coming/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/database%20possible%20problem-150x150.jpg&h=75&w=100&q=95" alt="Storm is coming" width="100" height="75" />
 Storm is coming </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to MS-SQL Stored Procedure for Absolute Beginner, Part 1" href="http://sodeve.net/2007/03/ms-sql-stored-procedure-for-absolute-beginner-part-1/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="MS-SQL Stored Procedure for Absolute Beginner, Part 1" width="100" height="75" />
 MS-SQL Stored Procedure for Absolute Beginner, Part 1 </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Reading CSV File with .NET" href="http://sodeve.net/2007/04/reading-csv-file-with-net/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="Reading CSV File with .NET" width="100" height="75" />
 Reading CSV File with .NET </a>
 
 </li>
 
  
</ul>


&nbsp;]]></description>
			<content:encoded><![CDATA[<p>SQL SMO (SQL Management Object) is a collection of assemblies that shipped together with SQL 2005. This collection of assemblies is all that you need to control your SQL Server. Be it SQL 2005, or SQL 2000, you can control/manipulate it programmatically using SQL SMO.</p>
<p>Since SQL SMO gave you the ability to treat the database elements such as Table, Database, Stored Procedure, and Trigger as an object, interacting with them should be relatively easy and practical. Additionally, you might want to check out this list of things that make <a href="http://suburbandestiny.com/tech/?p=159">SQL SMO exciting</a>.</p>
<p>OK, lets get our hand dirty with the project. The first step would be importing the references into your project. If you use Visual Studio 2005, look for Microsoft.SqlServer.Smo in the list of .NET assembly when you open &#8216;Add References&#8217; window.<br />
If you already have MS SQL 2005 installed, you can find the DLLs in the SDKAssemblies folder of your MS SQL 2005 installation folder.<br />
If you don&#8217;t have MS SQL 2005 installed in your computer, you might want to download the Express edition <a href="http://www.microsoft.com/downloads/details.aspx?familyid=220549B5-0B07-4448-8848-DCC397514B41&#038;displaylang=en">HERE</a>. </p>
<p>Next, you could use the following code as reference.</p>
<pre name="code" class="csharp">
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using System;
using System.Configuration;
using System.Data.SqlClient;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //Assuming that you include a Configuration file to your
            //project and set the key 'DataSource'
            //as the connection string
            SqlConnection conn = new SqlConnection(
                      ConfigurationManager.AppSettings["DataSource"]
            );
           //Instantiate the connection to the server
	   ServerConnection dbConn = new ServerConnection(conn);
	   //Instantiate the Database Server Object
	  Server dbServer = new Server(dbConn);			

          //Traverse the Database Objects
          foreach (Database db in dbServer.Databases)
          {
              if (db.IsAccessible)
              {
                  //traverse the Stored Procedure Objects
                  foreach (StoredProcedure sp in db.StoredProcedures)
                  {
                      foreach (string str in sp.Script())
                          Console.WriteLine(str);
                  }
                  //Traverse the Table Objects
                  foreach (Table tb in db.Tables)
                  {
                      foreach (string str in tb.Script())
                          Console.WriteLine(str);
                  }
                  //Traverse the View Objects
                  foreach (View vw in db.Views)
                  {
                      foreach (string str in vw.Script())
                          Console.WriteLine(str);
                  }
              }
          }
      }
  }
}
</pre>
<p>Make sure in your app.config you have the DataSource key. You can follow this template for the configuration file:</p>
<pre name="code" class="xml">
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="DataSource" value="data source=db_hostname;initial catalog=db_name;UID=user_id;PWD=password"></add>
  </appSettings>
</configuration>
</pre>
<p>Have fun!</p>
<p>&nbsp;</p>
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to Storm is coming" href="http://sodeve.net/2006/04/storm-is-coming/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/database%20possible%20problem-150x150.jpg&h=75&w=100&q=95" alt="Storm is coming" width="100" height="75" />
 Storm is coming </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to MS-SQL Stored Procedure for Absolute Beginner, Part 1" href="http://sodeve.net/2007/03/ms-sql-stored-procedure-for-absolute-beginner-part-1/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="MS-SQL Stored Procedure for Absolute Beginner, Part 1" width="100" height="75" />
 MS-SQL Stored Procedure for Absolute Beginner, Part 1 </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Reading CSV File with .NET" href="http://sodeve.net/2007/04/reading-csv-file-with-net/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="Reading CSV File with .NET" width="100" height="75" />
 Reading CSV File with .NET </a>
 
 </li>
 
  
</ul>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/2007/07/traversing-database-server-using-sql-smo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Prevent Error Caused By Null-Value in Your Stored Procedure</title>
		<link>http://sodeve.net/2007/04/prevent-error-caused-by-null-value-in-your-stored-procedure/</link>
		<comments>http://sodeve.net/2007/04/prevent-error-caused-by-null-value-in-your-stored-procedure/#comments</comments>
		<pubDate>Fri, 20 Apr 2007 10:35:33 +0000</pubDate>
		<dc:creator>Hardono</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://sodeve.net/prevent-error-caused-by-null-value-in-your-stored-procedure/</guid>
		<description><![CDATA[Consider we have a stored procedure that perform a SELECT operation for an object which is characterized by the 'Start Date' and 'End Date'. Let's assume we have the following TABLE:

Table Name:  Events
<dl>
     <dt>Columns: <dt>
          <dd>EventID int</dd>
          <dd>EventName Varchar(64)</dd>
          <dd>EventDesc Varchar(512)</dd>
          <dd>EventStartDate DateTime</dd>
           <dd>EventEndDate DateTime</dd>
   </dl>

&nbsp;
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to MS-SQL Stored Procedure for Absolute Beginner, Part 1" href="http://sodeve.net/2007/03/ms-sql-stored-procedure-for-absolute-beginner-part-1/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="MS-SQL Stored Procedure for Absolute Beginner, Part 1" width="100" height="75" />
 MS-SQL Stored Procedure for Absolute Beginner, Part 1 </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to MS SQL version of MySQL&#8217;s Group_Concat" href="http://sodeve.net/2006/01/ms-sql-version-of-mysqls-group_concat/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="MS SQL version of MySQL&#8217;s Group_Concat" width="100" height="75" />
 MS SQL version of MySQL&#8217;s Group_Concat </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Singapore Bus Guide on Handheld Device" href="http://sodeve.net/2007/04/singapore-bus-guide-on-handheld-device/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/134304173_550c5e8d32_t.jpg&h=75&w=100&q=95" alt="Singapore Bus Guide on Handheld Device" width="100" height="75" />
 Singapore Bus Guide on Handheld Device </a>
 
 </li>
 
  
</ul>


&nbsp;]]></description>
			<content:encoded><![CDATA[<p>Consider you have a stored procedure that perform a SELECT operation for an object which is characterized by the &#8216;Start Date&#8217; and &#8216;End Date&#8217;. Let&#8217;s assume we have the following TABLE:</p>
<p>Table Name:  Events</p>
<dl>
<dt>Columns:
<dt>
<dd>EventID int</dd>
<dd>EventName Varchar(64)</dd>
<dd>EventDesc Varchar(512)</dd>
<dd>EventStartDate DateTime</dd>
<dd>EventEndDate DateTime</dd>
</dl>
<p>And let&#8217;s assume that we have the following stored procedure:</p>
<pre name="code" class="sql">
CREATE PROCEDURE [dbo].[ListFilteredEvents]
	-- Add the parameters for the stored procedure here
	@StartDate datetime,
	@EndDate datetime
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

        -- Insert statements for procedure here
	SELECT
		Events.EventID,
		Events.EventName,
		Events.EventDesc,
		Events.EventStartDate,
		Events.EventEndDate
	FROM
		Events
	WHERE
		Events.EventStartDate>= @StartDate AND
                Events.EventEndDate<= @EndDate
	ORDER BY
		Events.EventStartDate
END
</pre>
<p>Now what will happen if somehow the SP caller will pass blank value as the StartDate and/or EndDate? Error (Exception will be thrown) of course. If we have access to the source code of the application that execute this stored procedure, we could easily error-prevention at the application level. But if our access is only limited to database level, we could do the following:</p>
<pre name="code" class="sql">
CREATE PROCEDURE [dbo].[ListFilteredEvents]
	-- Add the parameters for the stored procedure here
	@StartDate datetime,
	@EndDate datetime
AS
BEGIN
   IF @StartDate IS NULL
   BEGIN
      -- Set it with the smallest value of DateTime data type
      SET @StartDate=CAST('1753-01-01' as DATETIME)
   END

   IF @EndDate IS NULL
   BEGIN
      -- Set it with the biggest value of DateTime data type
      SET @EndDate=CAST('9999-12-31' as DATETIME)
   END

   BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

        -- Insert statements for procedure here
	SELECT
		Events.EventID,
		Events.EventName,
		Events.EventDesc,
		Events.EventStartDate,
		Events.EventEndDate
	FROM
		Events
	WHERE
		Events.EventStartDate>= @StartDate AND
                Events.EventEndDate<= @EndDate
	ORDER BY
		Events.EventStartDate
   END
END
</pre>
<p>This way we could prevent Error/Exception being thrown whenever a blank value is passed into the stored procedure.</p>
<p><strong>Important Update:</strong> <em>Saturday, 21 April 2007 13.43 PM</em> -- Thanks for Bro <a href="http://www.choirulamri.or.id/">MCA</a> for pointing out a better solution =)</p>
<pre name="code" class="sql">
CREATE PROCEDURE [dbo].[ListFilteredEvents]
	-- Add the parameters for the stored procedure here
	-- Set it with the smallest value of DateTime data type
        @StartDate DateTime='1753-01-01',
	-- Set it with the biggest value of DateTime data type
        @EndDate DateTime='9999-12-31'
AS
BEGIN
   -- SET NOCOUNT ON added to prevent extra result sets from
   -- interfering with SELECT statements.
   SET NOCOUNT ON;

   -- Insert statements for procedure here
   SELECT
	Events.EventID,
	Events.EventName,
	Events.EventDesc,
	Events.EventStartDate,
	Events.EventEndDate
   FROM
	Events
   WHERE
	Events.EventStartDate>= @StartDate AND
        Events.EventEndDate<= @EndDate
    ORDER BY
    Events.EventStartDate
END
</pre>
<p>&nbsp;</p>
<h3>Possibly Related Posts</h3>

 

<ul class="related-posts">

    <li> 
 <a title="Permanent Link to MS-SQL Stored Procedure for Absolute Beginner, Part 1" href="http://sodeve.net/2007/03/ms-sql-stored-procedure-for-absolute-beginner-part-1/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish1.jpg&h=75&w=100&q=95" alt="MS-SQL Stored Procedure for Absolute Beginner, Part 1" width="100" height="75" />
 MS-SQL Stored Procedure for Absolute Beginner, Part 1 </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to MS SQL version of MySQL&#8217;s Group_Concat" href="http://sodeve.net/2006/01/ms-sql-version-of-mysqls-group_concat/" rel="bookmark"><img src="/thumb/timthumb.php?src=fish2.jpg&h=75&w=100&q=95" alt="MS SQL version of MySQL&#8217;s Group_Concat" width="100" height="75" />
 MS SQL version of MySQL&#8217;s Group_Concat </a>
 
 </li>
 
 
    <li> 
 <a title="Permanent Link to Singapore Bus Guide on Handheld Device" href="http://sodeve.net/2007/04/singapore-bus-guide-on-handheld-device/" rel="bookmark"><img src="/thumb/timthumb.php?src=http://sodeve.net/wp-content/uploads/2011/11/134304173_550c5e8d32_t.jpg&h=75&w=100&q=95" alt="Singapore Bus Guide on Handheld Device" width="100" height="75" />
 Singapore Bus Guide on Handheld Device </a>
 
 </li>
 
  
</ul>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/2007/04/prevent-error-caused-by-null-value-in-your-stored-procedure/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for ( sssodeveee sodeve.net/category/database/feed/ ) in 5.82387 seconds, on Feb 5th, 2012 at 11:21 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 6th, 2012 at 11:21 am UTC -->
