<?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/"
	>
<channel>
	<title>  Databases</title>
	<link>http://databases.assistProgramming.com</link>
	<description>Codding World &#187; Databases</description>
	<pubDate>Sat, 23 Aug 2008 05:10:57 +0000</pubDate>
	<language>en</language>
			<item>
		<title>Create SQL Trigger</title>
		<link>http://databases.AssistProgramming.com/create-sql-trigger.html</link>
		<pubDate>Sun, 08 Jun 2008 16:18:20 +0000</pubDate>
		<description><![CDATA[General
A trigger is a stored procedure that automatically executes when an event occurs in the database server.Triggers execute when  users  try to modify something or  behind an event that generate  changes on the data base.There are three kind of triggers: for insert , update , and delete.The most important  events [...]]]></description>
			<content:encoded><![CDATA[<h2><strong>General</strong></h2>
<p>A trigger is a stored procedure that automatically executes when an event occurs in the database server.Triggers execute when  users  try to modify something or  behind an event that generate  changes on the data base.There are three kind of triggers: for <strong>insert , update ,</strong> and <strong>delete</strong>.The most important  events  correspond to Transact-<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> CREATE, ALTER, and DROP statements, and certain system stored procedures that perform DDL-like(data definition language) operations.Triggers can be created in the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 2005 Database Engine directly from Transact-<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> statements or from methods of assemblies that are created in the Microsoft .NET Framework common language runtime (CLR) and uploaded to an instance of <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server.Using <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server you can create lots of triggers for any specific statement.</p>
<h2>Syntax:</h2>
<pre>CREATE TRIGGER trigger_nameON { ALL SERVER | DATABASE }

[ WITH &lt;ddl_trigger_option&gt; [ ,...n ] ]

{ FOR | AFTER } { event_type | event_group } [ ,...n ]
AS { sql_statement  [ ; ] [ ,...n ] | EXTERNAL NAME</pre>
<pre>&lt; method specifier &gt;  [ ; ] }&lt;ddl_trigger_option&gt; ::=

[ ENCRYPTION ]

[ EXECUTE AS Clause ]

&lt;method_specifier&gt; ::=

assembly_name.class_name.method_name</pre>
<h3><em>schema_name</em></h3>
<p>Is the name of the schema to which a DML trigger belongs. DML triggers are scoped to the schema of the table or view on which they are created. <em>schema_name</em> cannot be specified for DDL or logon triggers.</p>
<h3><em>trigger_name</em></h3>
<p>Trigger name is the name of the trigger. Is not allowed to start the trigger name with # or ##.</p>
<h3><em>table/view</em></h3>
<p>Table or view are the table or view where trigger is executing on.Triggers cannot be defined on local or global temporary tables.</p>
<p><strong>DATABASE</strong></p>
<p>Current data base where changes are making on.</p>
<p><strong>ALL SERVER</strong></p>
<p>Is the current server where are the tables or views that we make changes.If specified, the trigger fires whenever <em>event_type</em> or <em>event_group</em> occurs anywhere in the current server.</p>
<p><strong>WITH ENCRYPTION</strong></p>
<p>Using WITH ENCRYPTION prevents the trigger from being published as part of <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server replication.</p>
<p><strong>EXECUTE AS</strong></p>
<p>Specifies the way is executed the trigger.This way users validate permissions on any database objects that are referenced by the trigger.</p>
<p><strong>FOR | AFTER</strong></p>
<p>After - means that trigger can be executed only after all operations  specified in the triggering <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> statement have executed successfully.</p>
<h3><em>event_type</em></h3>
<p>Is the type of event that release the trigger for executing.</p>
<h3><em>sql_statement</em></h3>
<p>Is the trigger conditions and actions. Trigger conditions specify additional criteria that determine whether the tried DML, DDL, or logon events cause the trigger actions to be performed.The trigger actions specified in the Transact-<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> statements go into effect when the operation is tried.</p>
<h3><em> method_specifier </em></h3>
<p>The method must take no arguments and return void. <em>class_name</em> must be a valid <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server identifier and must exist as a class in the assembly with assembly visibility. If the class has a namespace-qualified name that uses &#8216;.&#8217; to separate namespace parts, the class name must be delimited by using [ ] or &#8221; &#8221; delimiters. The class cannot be a nested class.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Mysql Sort records by some specific field values</title>
		<link>http://databases.AssistProgramming.com/mysql-sort-records-by-some-specific-field-values.html</link>
		<pubDate>Thu, 20 Mar 2008 07:03:13 +0000</pubDate>
		<description><![CDATA[Suppose the following scenario:
We have a mysql table that stores all orders of an online store. Each order has off course a field that represents the status of this order. That can be &#8216;pending&#8217;, &#8216;payment_received&#8217;, &#8216;approved&#8217;, &#8217;shipped&#8217;, &#8216;completed&#8217; .
Those statuses are found in the majority off good online stores so this is a practical theory.
Now [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose the following scenario:</p>
<p>We have a mysql table that stores all orders of an online store. Each order has off course a field that represents the status of this order. That can be &#8216;pending&#8217;, &#8216;payment_received&#8217;, &#8216;approved&#8217;, &#8217;shipped&#8217;, &#8216;completed&#8217; .</p>
<p>Those statuses are found in the majority off good online stores so this is a practical theory.</p>
<p>Now what if we want to list all orders, but sorted like 1st the &#8216;pending&#8217; ones, 2nd the &#8216;payment_received&#8217; ones, 3rd the &#8216;approved&#8217; one 4th the shipped ones and last the &#8216;completed&#8217;. Off curse if you think of it from the beginning you&#8217;ll probably structure your table such way so that is wasy to be done by a simple <em>sort by . </em>But what if your application is already done and you just need to add this small thing?</p>
<p>Well mysql can save from a ton of work . You can use advanced decision statements on the group by. We&#8217;ll just use a <strong>switch </strong>type of statement and we&#8217;ll basicly assign each value of the status a numeric value and we&#8217;ll sort on that.</p>
<p>Here is how the order by clause would look like :</p>
<pre>
ORDER BY

CASE order_status

      WHEN 'pending'   THEN 1

      WHEN 'payment_received'   THEN 2

      WHEN 'approved' THEN 3

      WHEN 'shipped'   THEN 4

      WHEN 'completed' THEN 5

      ELSE 99999

END</pre>
<p>The above will do exactly what we want. Will test the values of order_status field and will assign to that a numerical value used jst for search. Such a nice thing that does your life much easier when you really need it&#8230;</p>
]]></content:encoded>
			</item>
		<item>
		<title>Executing SQL Server Stored Procedure from Perl</title>
		<link>http://databases.AssistProgramming.com/executing-sql-server-stored-procedure-from-perl.html</link>
		<pubDate>Wed, 23 Jan 2008 11:28:04 +0000</pubDate>
		<description><![CDATA[Perl language is the most useful administration language on the Unix/Linux environment. Since Web technologies have risen in popularity, Perl also became a main development language for Internet-based development. Perl programming, such as CGI, Fast-CGI, mod_perl, Apache::ASP (very similar to Microsoft’s ASP 3.0), and Embedded-perl are used to create dynamic web pages and have become [...]]]></description>
			<content:encoded><![CDATA[<p>Perl language is the most useful administration language on the Unix/Linux environment. Since Web technologies have risen in popularity, Perl also became a main development language for Internet-based development. Perl programming, such as <acronym title='Common Gateway Interface'><span class='caps'>CGI</span></acronym>, Fast-<acronym title='Common Gateway Interface'><span class='caps'>CGI</span></acronym>, mod_perl, Apache::ASP (very similar to Microsoft’s ASP 3.0), and Embedded-perl are used to create dynamic web pages and have become very successful web solutions.Today’s website cannot leave out database support. Combining Perl and <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server (Sybase or Microsoft) is a natural way for those companies who want to migrate from traditional client-server architectures to Internet-based architectures for expanding their business. New companies also benefit from low ownership and cost by choosing a Perl and <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server solution.</p>
<p>In this article, I will show you how to setup a development environment using Perl and <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server on the following platforms: Microsoft Windows, Red Hat Linux, and Sun Solaris. Step by step, you can learn, and may choose, the best way that fits into your own requirements.</p>
<p><acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server was a product that originated from Sybase Inc., and became a popular DBMS product on the market from the end of 1980s.  In the early days Sybase <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server was running on the UNIX platform while PCs still used MS DOS (single task OS) – an operating system which was not suitable to develop and run a DBMS.</p>
<p>In 1987, Sybase and Microsoft signed a contract on joint development to port <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server to OS/2 (Multi-task OS) which became the replacement for MS DOS (OS/2 owned by both IBM and Microsoft). The OS/2 project did not continue for long, and Microsoft decided to develop its own multi-task operating system (Windows) and stop its contract with IBM. In 1990, with the successful release of Windows 3.0, Microsoft also released its Windows version of <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server – Microsoft <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server.</p>
<p>Milestones for MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server:</p>
<ul>
<li>MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 4.2 (16-bits, Jan. 1992)</li>
<li>MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server for Windows NT (32-bits, July, 1993)</li>
<li>MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 6.0 (June, 1995)</li>
<li>MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 6.5 (April, 1996)</li>
<li>MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Sever 7.0 (Nov. 1998)</li>
<li>MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 2000 (Aug. 2000)</li>
</ul>
<p>At the same time, Sybase dominated the Unix DBMS market.  From Sybase <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 4.2 (released around 1989, introduced unions), Version 4.8 (1990, introduced multiprocessor architecture), Version 4.9 (1992, more stable product, support SMP) Version 10 (1993, introduced server-side cursor, auditing and backup server), Version 11, Sybase Adaptive Server 12, until today: Sybase Adaptive Server 12.5.</p>
<p>Although in 1994, Microsoft and Sybase announced the end of the contract on joint <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server Development, MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 6.5 and Sybase <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 10 and all their previous versions used the same core code and were easily able to access each other.</p>
<p>MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 7.0 changed completely from its previous version and was no longer compatible with Sybase <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server. But, with the release of Service Pack 2 for <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 7.0 (Microsoft Knowledge Base Article – 239883 “Fix: SYBASE CT-Library Clients Cannot Connect to Microsoft <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 7.0”) we had one last chance to access MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 7.0 from the Sybase Client (Sybase <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server was more compatible with MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server, as you could successfully access Sybase <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server from the MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 2000 client, iSQL).</p>
<h3>Executing <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server Stored Procedure from Perl - TDS protocol</h3>
<p><acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server uses a typical Client-Server architecture. The <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server client is a set of C APIs plus management tools such as iSQL query tool and <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server Enterprise Manager. <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server Server-Side component is usually a system service, listening to specific <acronym title='Transmission Control Protocol'><span class='caps'>TCP</span></acronym> ports (Microsoft use 1433, Sybase use 4100 or 5000), and is ready to accept the signal from an <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server client at anytime.</p>
<p>The protocol used between an <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server client and server is traditionally called the TDS protocol (Tabular Data Stream). Microsoft <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 4.2, 6.0, and 6.5 use the same TDS protocol as Sybase <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 4.2 and 10, which is known as TDS4.2.</p>
<p>From Version 11, Sybase stopped further development of the old set of APIs (we call DB-Library) and started a new set of APIs, known as CT-library. They also redesigned the TDS protocol, which is now known, industry-wide, as TDS 5.0. At the same time, Microsoft chose to stick to DB-Library but enhanced the TDS protocol, which we call TDS 7.0.  But, do not think that TDS 7.0 is more advanced than TDS 5.0 or compatible with TDS 5.0. In fact, TDS 7.0 belongs solely to Microsoft <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server (we’re better off to call it Microsoft TDS) and TDS 5.0 belongs specifically to Sybase (Sybase TDS).</p>
<p>So, we easily understand that the latest version of Microsoft <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server (2000) supports TDS 7.0 and TDS 4.2 (backwards compatibility) and Sybase <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server’s latest version 12.5 supports TDS 5.0 and TDS 4.2 (backwards compatibility).</p>
<h3>Executing <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server Stored Procedure from Perl - Setup Perl and <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server on Windows</h3>
<p>Perl’s running environment is integrated within the <font face="courier new, courier, mono">*nix</font> system. For Microsoft Windows operating systems, however, you need to download and install it by yourself.</p>
<p>There are a few Windows-based distributions of Perl. ActivePerl from ActiveState.com may be the most popular one. You can download it from:</p>
<p><a rel="nofollow" href="http://www.activestate.com/Products/ActivePerl/" rel="nofollow">http://www.activestate.com/Products/ActivePerl/</a></p>
<p>Choose the latest version of ActivePerl (5.8) (most recent Unix/Linux also uses Perl 5.8).</p>
<p>Installing ActivePerl on Windows is fairly easy. After installation you can use the following command to verify that perl is working:</p>
<p>From command prompt, input:</p>
<blockquote dir="ltr" style="margin-right: 0px"><p><font face="courier new, courier, mono">Perl –v</font></p></blockquote>
<p>It will show you something like:</p>
<p>This is perl,  v5.8.0 built for MSWin32-x86-multi-thread<br />
Copyright 1987-2002, Larry Wall</p>
<p>Download Sybase Adaptive Server 12.5 Developer Edition from the Sybase website for free: <a rel="nofollow" href="http://www.sybase.com/ase_125devel" rel="nofollow">www.sybase.com/ase_125devel</a></p>
<p>Installing and configuring Sybase Adaptive Server is also as easy as MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server.</p>
<p>If you want to use MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server as a database, install MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 7.0 with service pack 2.</p>
<p>Perl uses DBI/DBD architecture to access databases (DBI means Database Interface, DBD means Database Driver). With a specific DBD driver installed, Perl can use the same DBI <acronym title='Application Interface'><span class='caps'>API</span></acronym> to support different database systems.</p>
<p dir="ltr" style="margin-right: 0px">The DBI module is already installed with the ActivePerl distribution itself.  In order to support <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server, we need to download the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server DBD driver from cpan.org: <a rel="nofollow" href="http://www.cpan.org/" rel="nofollow">www.cpan.org</a>, search for the DBD-Sybase module, and download the latest version 1.01 source code: <font face="courier new, courier, mono">DBD-Sybase-1.01.tar.gz</font></p>
<p><em>Note:</em> there are a few other DBD Drivers that support both Sybase and Microsoft <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server on Windows, such as DBD::ADO; however, they can only be used on a Windows platform.</p>
<p>In order to compile and install the DBD::Sybase source code, we need a C compiler installed on Windows (I use Microsoft Visual C++ 6.0), and make sure <font face="courier new, courier, mono">nmake.exe</font> is available in the PATH.</p>
<p>Use a decompression utility (ie: Winzip) to extract DBD-Sybase-1.0.1.tar.gz to any available drive such as C:. You should now have the folder c:DBD-Sybase-1.01 that holds all the source code.</p>
<p>Change directory to the above folder, and issue the following command in the command prompt window:</p>
<blockquote dir="ltr" style="margin-right: 0px"><p><font face="courier new, courier, mono">Perl Makefile.PL</font></p></blockquote>
<p>You may receive a warning message, such as missing the following library: <font face="courier new, courier, mono">libtcl.lib</font>, <font face="courier new, courier, mono">libcomn.lib</font> and <font face="courier new, courier, mono">libintl.lib</font>.</p>
<p>Because we are using the Sybase CT-Library, <font face="courier new, courier, mono">libcs.lib</font> and <font face="courier new, courier, mono">libct.lib</font> are mandatory; others are optional, and we can ignore this warning. Sybase removes these static libraries from its version 12.5 of the Adaptive Server package. The run time libraries still do exist (ie: libtcl.dll, libcomn.dll, linintl.dll)</p>
<p><span class="txt">If you receive an error message other than the one above, please check the following environment variable: <font face="courier new, courier, mono">SYBASE and SYBASE_OCS<br />
%SYBASE%</font> should equal the directory root where Sybase Adaptive Server is installed (ie: C:sybase) and <font face="courier new, courier, mono">%SYBASE_OCS%</font> should equal OCS-12_5 for Sybase Adaptive Server 12.5</span></p>
<p>Issue the following command to compile the source code:</p>
<p><font face="courier new, courier, mono">Nmake</font></p>
<p>Then install the package by issuing this command:</p>
<p><font face="courier new, courier, mono">Nmake install</font></p>
<p>Using the following code, we can list all the DBD drivers we’ve installed with Perl:</p>
<blockquote dir="ltr" style="margin-right: 0px"><p><font face="courier new, courier, mono">#!/usr/bin/perl</font></p>
<p><font face="courier new, courier, mono">use strict;<br />
use DBI;<br />
my @drivers=DBI-&gt;available_drivers();<br />
print join(&#8221;n&#8221;,@drivers);<br />
print &#8220;n&#8221;;</font></p></blockquote>
<p>Copy and paste the above code in notepad, and save the file as <font face="courier new, courier, mono">dbi_drivers.pl</font>.</p>
<p>Issue the following command in the command prompt window:</p>
<blockquote dir="ltr" style="margin-right: 0px"><p><font face="courier new, courier, mono">perl dbi_drivers.pl</font></p></blockquote>
<h3> Executing <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server Stored Procedure from Perl - Create A Stored Procedure on Sybase Adaptive Server</h3>
<p>Create the following Stored Procedure on Sybase Adaptive Server (using the pubs2 database):</p>
<blockquote dir="ltr" style="margin-right: 0px"><p><font face="courier new, courier, mono">CREATE PROCEDURE dbo.sp_GetBooksByPrice<br />
@minPrice money,<br />
@maxPrice money,<br />
@lowestPricedBook varchar(100) OUTPUT,<br />
@highestPricedBook varchar(100) OUTPUT  </font></p>
<p><font face="courier new, courier, mono">AS<br />
BEGIN<br />
DECLARE @realminPrice money,  @realmaxPrice money, @totalBooks int<br />
SELECT * FROM titles WHERE price &gt;=@minPrice  AND price &lt;</font><a rel="nofollow" href="mailto:=@maxPrice" rel="nofollow"><font face="courier new, courier, mono">=@maxPrice</font></a><br />
<font face="courier new, courier, mono">SELECT @realminPrice = min(price) FROM titles WHERE price &gt;=@minPrice<br />
SELECT @realmaxPrice = max(price) FROM titles WHERE price &lt;</font><a rel="nofollow" href="mailto:=@maxPrice" rel="nofollow"><font face="courier new, courier, mono">=@maxPrice</font></a><font face="courier new, courier, mono"><br />
SELECT @lowestPricedBook =title FROM titles WHERE price = @realminPrice<br />
SELECT @highestPricedBook =title FROM titles WHERE price = @realmaxPrice<br />
SELECT @totalBooks = COUNT(title)  FROM titles WHERE price &gt;= @minPrice AND price &lt;= @maxPrice<br />
RETURN  @totalBooks<br />
END</font></p>
<p><span class="txt"></span></p>
<p align="left">The above Stored Procedure is a very typical one; it takes 2 input parameters and 2 output parameters. Running it, we will get one resultset, one return value and 2 output parameters values. Save the above <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> code as <font face="courier new, courier, mono">sp.sql</font>. We will use it later on our Unix/Linux platform.</p>
<p align="left">Open the PerlIDE application and input the following Perl code:</p>
<blockquote dir="ltr" style="margin-right: 0px">
<p align="left"><font face="courier new, courier, mono">#!/usr/bin/perl</font></p>
<p align="left"><font face="courier new, courier, mono">use strict;<br />
use DBI;<br />
my $server = &#8220;ibmxp&#8221;;<br />
my $db = &#8220;pubs2&#8243;;<br />
my $username = &#8220;sa&#8221;;<br />
my $password = &#8220;&#8221;;</font></p>
<p align="left"><font face="courier new, courier, mono">my $dbh = DBI-&gt;connect(&#8221;dbi:Sybase:$server&#8221;, $username,$password);<br />
$dbh-&gt;do(&#8221;use $db&#8221;);<br />
my $query = &#8220;declare @minPriceBook varchar(100), @maxPriceBook  varchar(100)<br />
exec sp_GetBooksByPrice @minPrice =2.00 , @maxPrice = 20.00, @lowestPricedBook = @minPriceBook OUTPUT, @highestPricedBook  = @maxPriceBook OUTPUT&#8221;;<br />
my $sth = $dbh-&gt;prepare($query);<br />
$sth-&gt;execute();<br />
do {<br />
while(my $d = $sth-&gt;fetchrow_arrayref) {<br />
if ($sth-&gt;{syb_result_type}==4040){<br />
print join(&#8221;t&#8221;, @$d),&#8221;n&#8221;;<br />
}<br />
if ($sth-&gt;{syb_result_type}==4042){<br />
print &#8220;The lowest price book is: &#8220;, $d-&gt;[0], &#8220;n&#8221;;<br />
print &#8220;The highest price book is: &#8220;, $d-&gt;[1], &#8220;n&#8221;;<br />
}<br />
if ($sth-&gt;{syb_result_type}==4043){<br />
print &#8220;There are total: &#8220;, $d-&gt;[0], &#8221; books returnedn&#8221;;<br />
}<br />
}<br />
} while($sth-&gt;{syb_more_results});<br />
$sth=undef;<br />
$dbh-&gt;disconnect;</font></p>
<p>Save the Perl code as <font face="courier new, courier, mono">sybase_sp.pl</font> and from the command prompt window, issue the following command:</p>
<blockquote dir="ltr" style="margin-right: 0px"><p><font face="courier new, courier, mono">Perl sybase_sp.pl</font></p></blockquote>
<p>We get the same result!</p>
<p>Please notice that the constant value used to identify <font face="courier new, courier, mono">$sth-&gt;{syb_result_type}</font> comes from the Sybase CT-Library<br />
<acronym title='Application Interface'><span class='caps'>API</span></acronym> header file <font face="courier new, courier, mono">cspublic.h</font>:</p>
<blockquote dir="ltr" style="margin-right: 0px"><p><font face="courier new, courier, mono"> #define CS_ROW_RESULT  (CS_INT)4040<br />
#define CS_CURSOR_RESULT (CS_INT)4041<br />
#define CS_PARAM_RESULT (CS_INT)4042<br />
#define CS_STATUS_RESULT (CS_INT)4043<br />
#define CS_MSG_RESULT  (CS_INT)4044<br />
#define CS_COMPUTE_RESULT (CS_INT)4045</font></p></blockquote>
<p>We can use the same Perl code to execute the stored procedure on MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server 7.0 with service pack 2.</p>
<p>Open the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server Query Analyzer, select the pubs database and run the above Stored Procedure code. You can check the Stored Procedure from <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server Enterprise Manager;</p>
<p><span class="txt">I use the Sybase dsedit utility to edit the Sybase interface file, and add my Microsoft <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server entry into the interface file. My machine name where MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server is installed is home2k; we can ping this server from the dsedit menu button, and make sure it is connected. See the following screenshots:</span></p>
<p>(You can also manually edit %SYBASE%inisql.ini. On Unix/Linux Sybase uses the file called interface in the $SYBASE root directory, same functionality as sql.ini)</p>
<p><span class="txt">Modify our Perl code as follows:</span></p>
<blockquote dir="ltr" style="margin-right: 0px"><p><font face="courier new, courier, mono">my $server = &#8220;home2k&#8221;;<br />
my $db = &#8220;pubs&#8221;;</font></p></blockquote>
<p>Other parts of the code remain unchanged. Run the code again, this time, we get the stored procedure running on MS <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server, and get the same result.</p>
<p><span class="txt">Save the above Perl code as mssql_sp.pl. We will use it on Unix/Linux platform later on.</span></p>
<p><font face="courier new, courier, mono">See the <a rel="nofollow" href="http://www.devarticles.com/c/a/SQL-Server/Executing-SQL-Server-Stored-Procedure-from-Perl/">source</a>.</font></p>
<p align="left">&nbsp;</p>
</blockquote>
</blockquote>
]]></content:encoded>
			</item>
		<item>
		<title>Oracle&#8217;s Wrap Utility</title>
		<link>http://databases.AssistProgramming.com/oracles-wrap-utility.html</link>
		<pubDate>Sun, 18 Nov 2007 06:53:27 +0000</pubDate>
		<description><![CDATA[One thing that Oracle and UPS have in common is that they both deal with  wrapped packages. Why bother with wrapping packages? One obvious reason is to  hide the contents from prying eyes. You can wrap a real package with nondescript  wrapping paper or use transparent cellophane. This idea of a choice [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that Oracle and UPS have in common is that they both deal with  wrapped packages. Why bother with wrapping packages? One obvious reason is to  hide the contents from prying eyes. You can wrap a real package with nondescript  wrapping paper or use transparent cellophane. This idea of a choice between  hiding and exposing packages (and other objects) in Oracle serves the same  purpose as wrapping your UPS package - you do not want prying eyes to see what&#8217;s  in your Oracle package.</p>
<h3>The PL/<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Wrap Utility</h3>
<p>Appendix C of the Oracle 9.2 <em>PL/<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> User&#8217;s Guide and Reference</em>  covers the wrap utility. With many applications, it is common to see directories  full of source code. Businesses can protect their intellectual property by  taking proactive measures to protect and safeguard copyrighted material. If a  company suspects copyright infringement is occurring, it is up to the company to  seek legal remedies. This approach to protecting intellectual property (source  code) is similar to closing the barn door after the cows have left. Perhaps the  sheer number of files and lines of code serves as a deterrent to this type of  theft.</p>
<p>If you or your company has developed algorithms that give your product a  competitive edge in the marketplace, it makes sense that you would want to  protect that code. All that needs to be exposed is the input. The internals of  what happens to that input or how the output is produced can be likened to the  black box approach in testing. With Oracle&#8217;s wrap utility, you can turn the  inner workings of your code into an impenetrable black box, for the most part,  to protect your property.</p>
<p>The &#8220;for the most part&#8221; caveat serves to alert you that wrap has some  limitations. The reference guide, in part, states, &#8220;String literals, number  literals and names of variables, tables and columns remain in plain text within  the wrapped file. Wrapping a procedure helps to hide the algorithm and prevent  reverse-engineering, but it is not a way to hide passwords or table names that  you want to be secret.&#8221;</p>
<p>Oracle allows you to wrap the code inside the following statements:</p>
<pre> CREATE [OR REPLACE] FUNCTION function_name

 CREATE [OR REPLACE] PROCEDURE procedure_name

 CREATE [OR REPLACE] PACKAGE package_name

 CREATE [OR REPLACE] PACKAGE BODY package_name

 CREATE [OR REPLACE] TYPE type_name ... OBJECT

 CREATE [OR REPLACE] TYPE BODY type_name</pre>
<p>A common practice is to leave specifications unwrapped and to wrap the  implementation of procedures and functions within the package body.</p>
<h3>Running the Wrap Utility</h3>
<p>Wrapping a package is amazingly simple, although there is one pitfall to  avoid. Among the 500 plus files in the ORACLE_HOME/bin directory you will see  wrap or WRAP depending on your operating system (a lot of the more common files  and directories on Windows are upper-cased for ease of readability and  identification).</p>
<p>Using wrap is as simple as this:</p>
<pre>c:ora9ibin wrap iname=input_file_name</pre>
<p>You can specify an output file as a second argument by using this format:</p>
<pre>c:ora9ibin wrap iname=input_file_name oname=output_file_name</pre>
<p>Once wrapped, a package cannot be unwrapped. With that in mind, and just like  what you would do with a real package, do not wrap the package until it is time  to ship it. This implies keeping a source code repository of the original code.  If a customer or user reports a bug against a wrapped package, there is no  unwrapping it at the customer&#8217;s site. You are going to have to ship another  wrapped package with the fix in it. You will be making the bug fix or  enhancement with the repository file and wrapping the new file.</p>
<h3>An Example of Using Wrap</h3>
<p>In a previous article, I used the DBMS_RANDOM package. A slightly modified  bit of code from that produces the following:</p>
<pre><acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>&gt; CREATE or REPLACE PROCEDURE wrap_it (seed_in NUMBER)

  2  IS

  3    v_rand INTEGER;

  4  BEGIN

  5    DBMS_RANDOM.INITIALIZE (seed_in);

  6    FOR i IN 1..5 LOOP

  7     v_rand := mod(abs(DBMS_RANDOM.RANDOM),45);

  8     dbms_output.put_line(i||': '||v_rand);

  9    END LOOP;

 10  END;

 11  /Procedure created.

<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>&gt; exec wrap_it(123456);

1: 37

2: 36

3: 18

4: 8

5: 32

PL/<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> procedure successfully completed.</pre>
<p>I can take the code for the wrap_it procedure and, well, wrap it. The code  for the procedure is in a file named wrap_example.sql.</p>
<pre>C:ora9i&gt;wrap iname=c:ora9iadminwrap_example.sqlPL/<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Wrapper: Release 10.1.0.2.0- Production on Thu Jul 15 22:11:18 2004

Copyright (c) 1993, 2004, Oracle.  All rights reserved.

Processing c:ora9iadminwrap_example.sql to wrap_example.plb</pre>
<p>Note how Oracle changed the file extension to &#8220;plb.&#8221; Can we see the contents  of the wrap_example.plb file? Sure, but will it be completely readable? Let&#8217;s  find out.</p>
<p>Opening wrap_example.plb in my general-purpose text editor, we see the following lines of text:</p>
<pre>CREATE or REPLACE PROCEDURE wrap_it wrapped

a000000

b2

abcd

abcd

abcd

abcd

abcd

abcd

abcd

abcd

abcd

abcd

abcd

abcd

abcd

abcd

abcd

7

e0 f7

uveH+zmPD1snPwtBZmL3T1hkxRcwgy7w154VfC9GAME+MzyOFMq0DNYH29gBazqoJJQ0Xemb

pdRvlWrC2UeKeKiS2uzT80HMAvKIMOYhjXZT4CrU98zgprrwl4jKnFKvFljUAnGx8GHexDSU

XRa3oykCJIUWEovu72mqAm0vttgZB9E/9E6y2HhxKdu1k8arcrHegHYAvF1pwn1e6sCFJg04

QGsN1g1JLYIklPGBDEEZInWt0w==/</pre>
<p>That looks fairly undecipherable to me. One thing to note is the location of  the output file. Using the example above, the new wrap_example.plb file was  created in the c:\ora9i (my ORACLE_HOME) directory.</p>
<p>Now we know the procedure works and that the file or script can be wrapped. I  will drop the procedure and re-create it using the plb file. If all goes well, I  should be able to execute the procedure as before.</p>
<pre><acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>&gt; drop procedure wrap_it;Procedure dropped.

<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>&gt; @c:ora9iwrap_example.plb

Procedure created.

<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>&gt; exec wrap_it(123456);

1: 37

2: 36

3: 18

4: 8

5: 32

PL/<acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> procedure successfully completed.</pre>
<h3>In Closing</h3>
<p>The wrap utility is very easy to use, so if you have code you would like to  protect, wrap it up. If the uncompiled or unwrapped version passes testing, so  will the wrapped version because Oracle guarantees portability of the code.</p>
<p>What are some situations where you would want to wrap your code? Schema  migration or alteration immediately comes to mind. Often times when there is a  database migration (going to a newer version), you will find application  developers or software manufacturers releasing a newer version of their product.  The point release or major release version probably incorporates schema changes.  Running wrapped update scripts helps protect your work. Keep in mind, though,  that if a malicious user is dedicated enough, pretty much any schema can be  reverse engineered, but why make it easy for him? Wrap it up and protect your  work. And that&#8217;s a wrap.</p>
<p><a rel="nofollow" href="http://www.dbasupport.com/oracle/ora9i/wrap_utility.shtml">See the source&#8230;</a></p>
]]></content:encoded>
			</item>
		<item>
		<title>Connecting to a database using MySql</title>
		<link>http://databases.AssistProgramming.com/connecting-to-a-database-using-mysql.html</link>
		<pubDate>Fri, 16 Nov 2007 08:09:34 +0000</pubDate>
		<description><![CDATA[Every time we work with MySql we have to connect to the database using some php functions. We may use this to connect different databases so I advice you to write this instructions in one separated file. This way you can easily edit it. Save this sequence in a file named connexion.php. For further applications [...]]]></description>
			<content:encoded><![CDATA[<p>Every time we work with MySql we have to connect to the database using some php functions. We may use this to connect different databases so I advice you to write this instructions in one separated file. This way you can easily edit it. Save this sequence in a file named connexion.php. For further applications just include this file using command include.</p>
<p>Look at the content of this file:</p>
<pre>
&lt;?php$hostname="localhost";$username="root";

$password="pass";

$database="test";$connexion=mysql_connect($hostname,$username,$password)

or die ("Can't connect to the database!");

$db=mysql_select_db($database,$connexion)

or die ("Database not found!");

?&gt;</pre>
<p><strong>mysql_connect() - </strong>we use this function for connecting to the database. This function has three parameters: the server name, the username and the password for connecting to the database. The $connexion variable can have two values: TRUE or FALSE depending  on the MySql server connexion. In case it fails we will receive the message contained in the die() function.</p>
<p><strong>mysql_select_db</strong> <strong>-</strong> this function will establish the database for connexion. This function has two parameters: the database name and the access identifier to the MySql server.  The $db variable will contains the message in case the database is not found.</p>
<p>You can modify the content of the connexion file corresponding to your database configuration:</p>
<p>$hostname=the server address</p>
<p>$username=the username for connexion to the database</p>
<p>$password= the password for connexion to the database</p>
<p>$database=the database name</p>
<p>After all the operation made with the database we have to close the connexion  using  mysql_close() function.</p>
<p><code>mysql_close($connexion);</code></p>
]]></content:encoded>
			</item>
		<item>
		<title>Advanced data filtering using mysql</title>
		<link>http://databases.AssistProgramming.com/advanced-data-filtering-using-mysql.html</link>
		<pubDate>Tue, 13 Nov 2007 22:46:09 +0000</pubDate>
		<description><![CDATA[In this tutorial you will find how to combine WHERE clauses for creating strong searching conditions. You will find also how to use the operators NOT and IN.
Combining WHERE Clauses
These can be used in two ways: AND clauses, OR clauses.
Operators: Specialized reserved words used for clauses unification or modification.
AND Operator
If you want to filter for [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial you will find how to combine WHERE clauses for creating strong searching conditions. You will find also how to use the operators NOT and IN.</p>
<h3>Combining WHERE Clauses</h3>
<p>These can be used in two ways: <strong>AND</strong> clauses, <strong>OR</strong> clauses.</p>
<p><strong>Operators:</strong> Specialized reserved words used for clauses unification or modification.</p>
<h4>AND Operator</h4>
<p>If you want to filter for more columns, use AND operator to add conditions to WHERE clause. The next code represent this:</p>
<pre>
SELECT prod_id,prod_price,prod_name FROMProducts WHERE  sale_id =´DLL01´ AND prod_price  &lt;= 4;</pre>
<p>I used this instruction to find out the name and price for all the products sold by the DLL01 seller as long as the price is maxim 4$. This WHERE clause is made by two conditions, and the reserved word AND is used for the unifications of the two specified conditions.</p>
<p><strong>Remember</strong>: AND is used for finding the lines which correspond all the specified conditions.</p>
<h4>OR Operator</h4>
<p>This operator is opposite the AND operator. Using this operator the result will contains lines which correspond one condition. The most database systems won&#8217;t evaluate the second condition as long as the first is true.</p>
<pre>
SELECT prod_name, prod_price FROM Products WHERE  sale_id = ´DLL01´ OR  sale_id  =´BRS01´;</pre>
<p>This instruction will find the name and the price for all the products of one of the 2 sellers.</p>
<p><strong>Remember</strong>: OR is used for finding lines which correspond one of the specified condition.</p>
<h4>The evaluation order</h4>
<p>WHERE clauses may contain as many AND, OR clauses.  Combining this two type of operators will allow for a sophisticated and complexed filtering. There is a problem in using both AND, OR operators. For example we need the products list which cost minimum 10$ and are sold by the DLL01 and BRS01 sellers. The below instruction contains a combination of AND and OR clauses for building a WHERE clause.</p>
<pre>
SELECT prod_name, prod_price FROM Products WHERE sale_id=´DLL01´ OR  sale_id =´BRS01´AND prod_price  &gt; =10;</pre>
<p>The result will be:</p>
<pre>
Pen  3.49, Pencil  3.49, Notebook  4.49, Book  11.9.</pre>
<p>If you look the result will see that the first results don&#8217;t have corresponding values so there were a problem. Why this happened?  The answer is the evaluation order. <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> as the most operating languages works with AND operators before OR operators. The earlier WHERE clause is interpreted this way: &#8220;<em>show me products which cost 10$ or more sold by the DLL01 seller and all the products sold by BRS01 no matter the price</em>&#8220;. So the conclusion is that the operators where unified in a wrong way. To solve this problem use brackets. So look at the below instruction:</p>
<pre>
SELECT prod_name,  prod _price FROM  Products WHERE  (sale_id  = ´DLL01´ OR  sale_id  =  ´BRS01´)</pre>
<p>We know that brackets has a highest priority, first will be analyzed the condition OR. So now we can interpret the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> command: &#8220;<em>show me all the products of the seller DLL01 or BRS01 which cost 10$ or more</em>&#8220;.</p>
<p><strong>Remember</strong>: When you have WHERE clauses which uses AND, OR operators use brackets to group in an explicitly way the operators.</p>
<h4>IN Operator</h4>
<p>We use this operator to specify a condition domain. IN necessities a list of valid values, which should be separated by commas and contents in brackets. Lets have an example in this way:</p>
<pre>
SELECT prod_name, prod_price FROM  Products WHERE sale_id  IN  (´DLL01´  ,´BRS01´) ORDER BY prod_name;</pre>
<p>We can observe that IN can be substitute by the OR operator. <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> will give us the same result as in the earlier example:</p>
<pre>
SELECT prod_name, prod_price FROM Products WHERE sale_id  =´DLL01´ OR  vanz_id = ´BRSO1´ORDER  BY  prod_name;</pre>
<p>So what are the IN advantages? When we have long lists of values using IN it is easiest to read. Almost always the IN operators are executed faster then OR lists. The big advantage is that IN may contain another SELECT instruction and this way you can build WHERE clause in a dynamic way.</p>
<h4>NOT Operator</h4>
<p>The NOT operator has a single function - deny any condition that comes after. The syntax for this operator is different. The next example show us how to use this operator. If you want to display the products of all the sellers less DLL01, you can write:</p>
<pre>
SELECT prod_name FROM Products</pre>
<pre>WHERE NOT sale_id  =´DLL01´ORDER  BY prod_name;</pre>
<p>The operator in this case deny the condition that comes after it. The NOT operator can be substitute with the &#8220;&lt;&gt;&#8221; operator. For simple clauses as we have here is not necessary using NOT operator. It can be used in complex clauses.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Tips for optimizing mysql queries</title>
		<link>http://databases.AssistProgramming.com/tips-for-optimizing-mysql-queries.html</link>
		<pubDate>Wed, 17 Oct 2007 21:30:23 +0000</pubDate>
		<description><![CDATA[
Use the explain command
Use multiple-row INSERT  statements to store many rows with one SQL statement. The explain command can tell you which indexes are used with the specified  query and many other pieces of useful information that can help you choose a  better index or query.Example of usage: explain select * from [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li><strong>Use the explain command</strong><br />
Use multiple-row INSERT  statements to store many rows with one <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> statement. The explain command can tell you which indexes are used with the specified  query and many other pieces of useful information that can help you choose a  better index or query.Example of usage: <em>explain select * from table</em><br />
explanation of row output:</p>
<ul>
<li>table—The name of the table.</li>
<li>type—The join type, of which there are several.</li>
<li>possible_keys—This column indicates which indexes MySQL could use to find  the rows in this table. If the result is NULL, no indexes would help with this  query. You should then take a look at your table structure and see whether there  are any indexes that you could create that would increase the performance of  this query.</li>
<li>key—The key actually used in this query, or NULL if no index was used.</li>
<li>key_len—The length of the key used, if any.</li>
<li>ref—Any columns used with the key to retrieve a result.</li>
<li>rows—The number of rows MySQL must examine to execute the query.</li>
<li>extra—Additional information regarding how MySQL will execute the query.  There are several options, such as Using index (an index was used) and Where (a  WHERE clause was used).</li>
</ul>
</li>
<li><strong>Use less complex permissions </strong>The more complex your permissions setup, the more overhead you have. Using  simpler permissions when you issue GRANT statements enables MySQL to reduce  permission-checking overhead when clients execute statements.</li>
<li><strong>Specific mysql functions can be tested using the built-in  “benchmark” command</strong> If your problem is with a specific MySQL expression or function, you can  perform a timing test by invoking the BENCHMARK() function using the mysql  client program. Its syntax is BENCHMARK(loop_count,expression). The return value  is always zero, but mysql prints a line displaying approximately how long the  statement took to execute</li>
<li><strong>Optimize where clauses</strong>
<ul>
<li>Remove unnecessary parentheses</li>
<li>COUNT(*) on a single table without a WHERE is retrieved directly from the  table information for MyISAM and MEMORY tables. This is also done for any NOT  NULL expression when used with only one table.</li>
<li>If you use the SQL_SMALL_RESULT option, MySQL uses an in-memory temporary  table</li>
</ul>
</li>
<li><strong>Run optimize table</strong> This command defragments a table after you have deleted a lot of rows from  it.</li>
<li><strong>Avoid variable-length column types when necessary </strong>For MyISAM tables that change frequently, you should try to avoid all  variable-length columns (VARCHAR, BLOB, and TEXT). The table uses dynamic row  format if it includes even a single variable-length column.</li>
<li><strong>Insert delayed </strong>Use insert delayed when you do not need to know when your data is written.  This reduces the overall insertion impact because many rows can be written with  a single disk write.</li>
<li><strong>Use statement priorities</strong>
<ul>
<li>Use INSERT LOW_PRIORITY when you want to give SELECT statements higher  priority than your inserts.</li>
<li>Use SELECT HIGH_PRIORITY to get retrievals that jump the queue. That is, the  SELECT is executed even if there is another client waiting.</li>
</ul>
</li>
<li><strong>Use multiple-row inserts</strong> Use multiple-row INSERT statements to store many rows with one <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>  statement.</li>
<li><strong>Synchronize data-types</strong> Columns with identical information in different tables should be declared to  have identical data types so that joins based on the corresponding columns will  be faster.</li>
</ul>
]]></content:encoded>
			</item>
		<item>
		<title>MySQL Stored procedures</title>
		<link>http://databases.AssistProgramming.com/mysql-stored-procedures.html</link>
		<pubDate>Fri, 21 Sep 2007 21:32:19 +0000</pubDate>
		<description><![CDATA[Do you want to know &#8220;what&#8217;s new&#8221; in version 5 of MySQL? There are new features added to this version like stored procedures, triggers, views, information_schema. For those who use MySQL for databases administration this is a very good news.
For a better understanding of the stored procedures importance I will give a definition and an [...]]]></description>
			<content:encoded><![CDATA[<p>Do you want to know &#8220;what&#8217;s new&#8221; in version 5 of MySQL? There are new features added to this version like <strong>stored procedures</strong>, <strong>triggers</strong>, <strong>views</strong>, <strong>information_schema.</strong> For those who use MySQL for databases administration this is a very good news.</p>
<p>For a better understanding of the stored procedures importance I will give a definition and an example. A <strong>stored procedure</strong> is a subroutine available to applications accessing a relational database system. A stored procedure has a name, a list of parameters and <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> statements. Bellow is a simple procedure whose name is <em>test</em> and has an integer parameter. This procedure insert in <em>person</em> table the value &#8220;<em>major</em>&#8221; or &#8220;<em>unknown</em>&#8221; depending &#8220;<em>a</em>&#8221; variable. In this type of procedures we can use instructions like &#8220;<em>IF ELSE END IF</em>&#8221; like in the example below.</p>
<pre>CREATE PROCEDURE test (IN a INTEGER)
BEGIN
  DECLARE age CHAR(10);  

  IF a = 18 THEN
    SET age = 'major';
  ELSE
    SET age = 'unknown';
  END IF;

  INSERT INTO person VALUES (age);

END</pre>
<h3>Why Stored Procedures</h3>
<p>Stored procedures are something new for MySQL but this concept isn&#8217;t new for other DBMSs. The syntax is almost the same and there are people with experience, there are articles, tutorials and forums about stored procedure.</p>
<p>The <strong>performance </strong>is one of the greatest advantages of stored procedures. Stored procedures are faster because they are pre-compiled <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> code. MySQL server has some caching advantages. If you have a repetitive task with some requirements my advice is to call a procedure stored on the server. If a bunch of <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> statements are sent to the server, repeatedly, they have to be optimized each time. The <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> statements in the stored procedure that is in memory have to only be optimized once and an execution plan is created for the <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> statements in the stored procedure.</p>
<p>Another advantage of stored procedures is <strong>portability</strong>. If you write your stored procedure in <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym>, you should know that it will run on every  platform that MySQL runs on, without obliging you to install an additional  runtime-environment package, or set permissions for program execution in the  operating system. This is an <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> advantage rather than an external language like Java, C++, <acronym title='PHP Hypertext Processor'><span class='caps'>PHP</span></acronym>.</p>
<p>Since the procedures are stored on the server there is an easy <strong>maintenance </strong>and<strong> </strong>we can make changes in one place rather than to a lot of <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> statements distributed all over the application.</p>
<p>We can create procedures who can permit the users to access some databases, rather than giving them full access. So this can be like <strong>security </strong>measurements.</p>
<p>Part II will come!</p>
]]></content:encoded>
			</item>
		<item>
		<title>Excel-DB</title>
		<link>http://databases.AssistProgramming.com/excel-db.html</link>
		<pubDate>Mon, 17 Sep 2007 20:06:42 +0000</pubDate>
		<description><![CDATA[The world&#8217;s most popular database spreadsheet interface with the tool for databases gives you built-in widgets to quickly interact with Oracle, MySQL and SQL Server.
Hypercharge your Spreadsheets with instant data!
You deserve fast and easy access to your data. Excel-DB is the time-tested solution to empower your spreadsheets with the data that they need, no hassle, [...]]]></description>
			<content:encoded><![CDATA[<p>The world&#8217;s most popular database spreadsheet interface with the tool for databases gives you built-in widgets to quickly interact with <strong>Oracle</strong>, <strong>MySQL </strong>and <strong><acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server</strong>.</p>
<p><strong>Hypercharge your Spreadsheets with instant data!</strong></p>
<p>You deserve fast and easy access to your data. Excel-DB is the time-tested solution to empower your spreadsheets with the data that they need, no hassle, no security risks.</p>
<p><strong>Break the chains of spreadsheet data analysis</strong></p>
<p>You deserve easy access to your database data, with Oracle MySQL and <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server. To be effective,  					you must have fast data access while maintaining security.</p>
<p>Excel-DB is the time-tested solution to empower you spreadsheets with the data that you need, no hassle, no security risks.</p>
<p><strong> Excel-DB for business professionals</strong></p>
<ul>
<li>Get the current data that you need, instantly</li>
<li>Use MS-Excel tools for advanced data analysis</li>
<li>Super-fast, super-easy interface to Oracle and <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server</li>
<li>Friendly wizard-based data interaction</li>
<li>Consolidate data from many different databases</li>
<li>Easy interface for Business Intelligence Analysis</li>
</ul>
<p><strong>Excel-DB for DBA’s:</strong></p>
<ul>
<li>Stop those “Why can’t I get my own data?” complaints</li>
<li>Quickly deploy database-enabled spreadsheets to your end-users</li>
<li>Safely deploy data without security risk</li>
<li>Get Business intelligence extraction with native <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym></li>
<li>Perform advanced analytics without expensive new tools</li>
</ul>
<p>Excel-DB is great for the <strong><acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server</strong> user and you can get your <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server data into your spreadsheet with a built-in toolbar. There is no need to buy expensive Business intelligence or data warehouse solutions for <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server, since all you need to do is download your <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server tables right into your spreadsheet.</p>
<p>Excel-DB is the perfect interface for <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server data.  You can directly extract and analyze current <acronym title='Structured Query Language'><span class='caps'>SQL</span></acronym> Server data, right in your excel spreadsheet and without cumbersome Microsoft ODBC.</p>
<p>Using Excel-DB is the best way to get <strong>Oracle </strong>data into your Excel spreadsheets and it has a native <acronym title='Application Interface'><span class='caps'>API</span></acronym>, directly into your Oracle database. Get Oracle tables into Excel!</p>
<p>Excel-DB gives you a direct and easy way to extract and analyze your <strong>MySQL </strong>data, right from your Excel Spreadsheet.</p>
<p>For more details about the product or about ordering <strong>Excel-DB </strong>visit <a rel="nofollow" href="http://www.excel-db.net/">http://www.excel-db.net/</a></p>
]]></content:encoded>
			</item>
		<item>
		<title>How to make a database faster?</title>
		<link>http://databases.AssistProgramming.com/how-to-make-a-database-faster.html</link>
		<pubDate>Sat, 08 Sep 2007 08:22:45 +0000</pubDate>
		<description><![CDATA[The big pain
Did you ever tried to work with some databases that contain big tables? And by BIG I mean one table at least that has more than 1 million records. No matter you are using MySql, SqlServer, Oracle or other DBMS, the problem is same: finding informations in that table ( records as we [...]]]></description>
			<content:encoded><![CDATA[<h2>The big pain</h2>
<p>Did you ever tried to work with some databases that contain big tables? And by <strong>BIG </strong>I mean one table at least that has more than 1 million records. No matter you are using MySql, SqlServer, Oracle or other DBMS, the problem is same: finding informations in that table ( records as we all know them) is very very slow. Can take minutes if the database is big and that&#8217;s really a pain.  <a href="http://www.assistprogramming.com/how-to-make-a-database-faster.html#more-19" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			</item>
	</channel>
</rss>
