<?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>is a software developer&#60;br&#62;in a pursuit of happyness</description>
	<lastBuildDate>Thu, 10 Jun 2010 19:06:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How To Execute Oracle Function From NHibernate</title>
		<link>http://sodeve.net/how-to-execute-oracle-function-from-nhibernate/</link>
		<comments>http://sodeve.net/how-to-execute-oracle-function-from-nhibernate/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 19:22:34 +0000</pubDate>
		<dc:creator>Hardono Arifanto</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, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sodeve.net/how-to-execute-oracle-function-from-nhibernate/nhib-logo04/" rel="attachment wp-att-905"><img src="http://sodeve.net/wp-content/uploads/2010/04/nhib-logo04.gif" alt="NHibernate" title="NHibernate" width="300" height="166" class="alignleft size-full wp-image-905" /></a>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.</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>
]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/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/how-to-connect-tora-to-oracle-database/</link>
		<comments>http://sodeve.net/how-to-connect-tora-to-oracle-database/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 16:28:22 +0000</pubDate>
		<dc:creator>Hardono Arifanto</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 get [...]]]></description>
			<content:encoded><![CDATA[<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>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>
<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 (refer to the first image):</p>
<p>
<div class="ngg-galleryoverview" id="ngg-gallery-7-763">


	
	<!-- Thumbnails -->
		
	<div id="ngg-image-127" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://sodeve.net/wp-content/gallery/tora/Tora Settings.png" title="TOra Connection with Instant Client" class="shutterset_set_7" >
								<img title="TOra Connection with Instant Client" alt="TOra Connection with Instant Client" src="http://sodeve.net/wp-content/gallery/tora/thumbs/thumbs_Tora Settings.png" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-128" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://sodeve.net/wp-content/gallery/tora/tora-tns.png" title="TOra Connection with TNS" class="shutterset_set_7" >
								<img title="TOra Connection with TNS" alt="TOra Connection with TNS" src="http://sodeve.net/wp-content/gallery/tora/thumbs/thumbs_tora-tns.png" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class='ngg-clear'></div>
 	
</div>

</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. Please refer to the screenshot, the second image of the above gallery.</p>
]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/how-to-connect-tora-to-oracle-database/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Oracle + IIS + ASP.NET Problem: RESOLVED</title>
		<link>http://sodeve.net/oracle-iis-asp-net-problem-resolved/</link>
		<comments>http://sodeve.net/oracle-iis-asp-net-problem-resolved/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 03:08:40 +0000</pubDate>
		<dc:creator>Hardono Arifanto</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' />]]></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>
]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/oracle-iis-asp-net-problem-resolved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle + IIS + ASP.NET Problem: Oracle client and networking components were not found</title>
		<link>http://sodeve.net/oracle-iis-aspnet-problem-oracle-client-and-networking-components-were-not-found/</link>
		<comments>http://sodeve.net/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 Arifanto</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.]]></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>
]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/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/sql-string-formatter-part-2/</link>
		<comments>http://sodeve.net/sql-string-formatter-part-2/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 16:58:13 +0000</pubDate>
		<dc:creator>Hardono Arifanto</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.]]></description>
			<content:encoded><![CDATA[<p>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>
]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/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/sql-string-formatter-part-1/</link>
		<comments>http://sodeve.net/sql-string-formatter-part-1/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 16:44:55 +0000</pubDate>
		<dc:creator>Hardono Arifanto</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, I&#8217;m [...]]]></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>
]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/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/traversing-database-server-using-sql-smo/</link>
		<comments>http://sodeve.net/traversing-database-server-using-sql-smo/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 11:31:37 +0000</pubDate>
		<dc:creator>Hardono Arifanto</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.]]></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>
]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/traversing-database-server-using-sql-smo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Prevent Error Caused By Null-Value in Your Stored Procedure</title>
		<link>http://sodeve.net/prevent-error-caused-by-null-value-in-your-stored-procedure/</link>
		<comments>http://sodeve.net/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 Arifanto</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>
]]></description>
			<content:encoded><![CDATA[<p>[excerpt]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>[/excerpt]<br />
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>
]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/prevent-error-caused-by-null-value-in-your-stored-procedure/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Singapore Bus Guide on Handheld Device</title>
		<link>http://sodeve.net/singapore-bus-guide-on-handheld-device/</link>
		<comments>http://sodeve.net/singapore-bus-guide-on-handheld-device/#comments</comments>
		<pubDate>Sat, 07 Apr 2007 14:15:17 +0000</pubDate>
		<dc:creator>Hardono Arifanto</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[singapore]]></category>

		<guid isPermaLink="false">http://sodeve.net/singapore-bus-guide-on-handheld-device/</guid>
		<description><![CDATA[<div class="image-right"><a href="http://www.flickr.com/photos/mr-dew/134304173/"><img src="http://farm1.static.flickr.com/51/134304173_550c5e8d32_t.jpg" /><br />(c) Mr Dew</a></div>When I'm travelling on Singapore Mass Rapid Transit (<a href="http://www.smrt.com.sg/">SMRT</a>), I often make myself busy with my HP RX3715. Especially when the <a href="http://www.smrt.com.sg/">MRT</a> is not crowded and I'm lucky enough to get a seat. The comfort condition is really supporting your creative mind, so better not waste it. Most of the time, I will open up Pocket Word, and jot down whatever ideas running in my head. Occasionally, I will revisit my old ideas and amend if not improve it. ]]></description>
			<content:encoded><![CDATA[<p>[excerpt]
<div class="image-right"><center><a href="http://www.flickr.com/photos/mr-dew/134304173/"><img src="http://farm1.static.flickr.com/51/134304173_550c5e8d32_t.jpg" /><br />(c) Mr Dew</a></center></div>
<p>When I&#8217;m travelling on Singapore Mass Rapid Transit (<a href="http://www.smrt.com.sg/">SMRT</a>), I often make myself busy with my HP RX3715. Especially when the <a href="http://www.smrt.com.sg/">MRT</a> is not crowded and I&#8217;m lucky enough to get a seat. The comfort condition is really supporting your creative mind, so better not waste it. Most of the time, I will open up Pocket Word, and jot down whatever ideas running in my head. Occasionally, I will revisit my old ideas and amend if not improve it. [/excerpt]</p>
<div class="image-left"><a href="http://www.flickr.com/photos/superciliousness/125508367/"><img src="http://farm1.static.flickr.com/54/125508367_7889f8d9fe_t.jpg" /><br />(c) superciliousness</a></div>
<p>I have been had this idea of creating a mini Bus Guide in <a href="http://www.streetdirectory.com/">Street Directory</a>-style in my HP RX3715 for quite sometimes. Although I yet to have clear way on the implementation, I&#8217;d like to share the idea with you all hoping for your feedbacks.</p>
<p>ALAS, apparently such guide <a href="http://mo-life.blogspot.com/2005/02/singapore-bus-guide-for-isilo-plucker_15.html">is already created</a>. But it is a static document. Anyway, I will carry on with this project, hopefully I will learn something about <a href="http://en.wikipedia.org/wiki/Embedded_system">Embedded System</a> utilising <a href="http://java.sun.com/javame/index.jsp">J2ME</a>/<a href="http://msdn.microsoft.com/mobility/netcf/">.NET Compact Framework</a>/C++ from this.</p>
<p>So far my idea is represented in T-SQL syntaxes.</p>
<div class="codediv">
<div class="codeclicker">&nbsp;</div>
<p><span class="codecontent"></p>
<p>/* Table for Bus */</p>
<p>
  Create Table Buses (<br />
&nbsp;&nbsp;Bus_ID int Identity(1,1) not null,<br />
&nbsp;&nbsp;Bus_Name varchar(6) not null<br />
)</p>
<p>/* Table for Bus routes */ <br />
  Create Table Bus_routes(<br /> <br />
  &nbsp;&nbsp;Bus_ID int,<br />
  &nbsp;&nbsp;Bus_Stop_Address varchar(64) not null,<br /> <br />
  &nbsp;&nbsp;Seq_Number  int /* to make routes possible */<br />
  <br />
)</p>
<p> /*<br /> <br />
  &nbsp;&nbsp;Get available bus in a particular address<br /> <br />
  &nbsp;&nbsp;Param: @street<br />
  */<br />
  <br />
  Select distinct Bus_Name from Buses b inner join Bus_routes br on b.Bus_IDr =br.Bus_ID <br />
  where Bus_Stop_Address like &#8216;%@street%&#8217; order by Bus_Name</p>
<p> /*<br /> <br />
  &nbsp;&nbsp;Select a bus based on Start and destination, Direct Bus<br /> <br />
  &nbsp;&nbsp;Parameter: @route_start, @route_end<br />
  */<br />
  <br />
  Select distinct Bus_Name from Bus_Routes a inner join Bus_Routes b on a.Bus_ID= b.Bus_ID and <br />
  a. Seq_Number <= b.Seq_Number inner join Buses bs on a.Bus_ID=bs.Bus_ID<br /> <br />
  where a.Bus_Stop_Address like &#8216;%@route_start%&#8217; and b.bus_stop_address like &#8216;%@route_end%&#8217;<br /> <br />
  order by bs.Bus_Name</p>
<p>/*<br /> <br />
  &nbsp;&nbsp;View Bus&#8217; route<br />
  &nbsp;&nbsp;Param: @busname<br />
  <br />
  */<br />
  <br />
  Select Bus_Stop_Address From Buses b inner join Bus_Routes br on b.Bus_ID=br.Bus_ID<br />
  <br />
Where b.Bus_Name = &#8216;@busname&#8217; order by br.Seq_Number</p>
<p> /*<br />
  &nbsp;&nbsp;Indirect Route with the smallest number of changing Bus<br />
  &nbsp;&nbsp;I&#8217;ll think about this <strong>on my next travel</strong> on MRT <img src='http://sodeve.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <br />
  */</p>
<p></span>
</div>
<p>Any Suggestions?</p>
]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/singapore-bus-guide-on-handheld-device/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MS-SQL Stored Procedure for Absolute Beginner, Part 1</title>
		<link>http://sodeve.net/ms-sql-stored-procedure-for-absolute-beginner-part-1/</link>
		<comments>http://sodeve.net/ms-sql-stored-procedure-for-absolute-beginner-part-1/#comments</comments>
		<pubDate>Mon, 26 Mar 2007 04:51:14 +0000</pubDate>
		<dc:creator>Hardono Arifanto</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://sodeve.net/database/stored-procedure/ms-sql-stored-procedure-for-absolute-beginner-part-1/</guid>
		<description><![CDATA[Currently I am reading a book about MS SQL Stored Procedure. I need to read the book as an anticipation that i will be accepted to an Insurance Company. Just to make sure my brain is not rusty :-P. I believe in-order to understand this guide, you need to know the basic <a href="http://en.wikipedia.org/wiki/Data_Definition_Language">Data Creation</a> and <a href="http://en.wikipedia.org/wiki/Data_Manipulation_Language">Data Modification</a> commands in <a href="http://en.wikipedia.org/wiki/Transact-SQL">T-SQL</a>. I will use this posting to share with you what i *roughly* get from the book :)

<dl> <dt>
</dt>
<h3>1. What is Stored Procedure?</h3>
<dd>Stored procedure is a collection of queries/commands encapsulated in a function stored in the database server. The function may receive parameters which later can be used as the paremeters of the queries/commands. <a href="http://www.google.com/search?hl=en&#38;q=stored%20procedure">More definition</a>. </dd> <dt>
</dt> <dt>
</dt></dl>]]></description>
			<content:encoded><![CDATA[<p>Currently I am reading a book about MS SQL Stored Procedure. I need to read the book as an anticipation that i will be accepted to an Insurance Company. Just to make sure my brain is not rusty <img src='http://sodeve.net/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> . I believe in-order to understand this guide, you need to know the basic <a href="http://en.wikipedia.org/wiki/Data_Definition_Language">Data Creation</a> and <a href="http://en.wikipedia.org/wiki/Data_Manipulation_Language">Data Modification</a> commands in <a href="http://en.wikipedia.org/wiki/Transact-SQL">T-SQL</a>. I will use this posting to share with you what i *roughly* get from the book <img src='http://sodeve.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<dl>
<dt>
</dt>
<h3>1. What is Stored Procedure?</h3>
<dd>Stored procedure is a collection of queries/commands encapsulated in a function stored in the database server. The function may receive parameters which later can be used as the paremeters of the queries/commands. <a href="http://www.google.com/search?hl=en&amp;q=stored%20procedure">More definition</a>. </dd>
<dt>
</dt>
<dt>
</dt>
<h3>2. Why Stored Procedure (SP) is useful?</h3>
<dd>Because SP will encapsulated your queries/commands into a parameterized queries/data definitions/data modifications. Thus you can standardize the exchange of information between the database server and its users. At the same time you will reduce the debugging-time on Application development since all the business logic are stored in the database. SP also able to help you maintaining security by classifying which users are permitted and which users prohibited to call the Stored Procedures. </dd>
<dt>
</dt>
<dt>
</dt>
<h3>3. Why we need Stored Procedure (SP) ?</h3>
<dd>Because we want to achieve result mentioned on number 2. We can achieve this by replacing the Stored Procedure as a library of functions stored outside the database server. But it will hinder the flexibility of type of Application that using the same business logic. For example,  the current business application is using Web-based interface; If we want to create a Desktop-based/<a href="http://en.wikipedia.org/wiki/Smart_client">Smart Client Application</a> we will be using more time to translate the business logic into different programming language/framework. We also will have major headache if we need to upgrade the Application but not the <a href="http://en.wikipedia.org/wiki/Business_logic">Business Logic</a>. </dd>
<dt>
</dt>
<dt>
</dt>
<h3>4. Why we DON&#8217;T need Stored Procedure (SP) ?</h3>
<dd>Because SP is less powerful compared to the programming language that we use on the Web Application/Desktop Application/Smart Client. It also possible that we will locked into only one RDBMS vendor. Thus reducing our flexibility in managing IT budget. </dd>
<dt>
</dt>
<dt>
</dt>
<h3>5. When a Stored Procedure is suited Us best?</h3>
<dd>When you are confident that the current RDBMS will be deployed in your organization long enough compared to the time to develop the stored procedure. Extending the application into multiple platform/programming language is mentioned in your Application&#8217;s Development Roadmap.</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://sodeve.net/ms-sql-stored-procedure-for-absolute-beginner-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
