<?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>BDC Software &#187; Database</title>
	<atom:link href="http://www.bdcsoftware.com/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bdcsoftware.com</link>
	<description>Experience Matters</description>
	<lastBuildDate>Fri, 04 Jun 2010 17:55:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Five Years with Firebird</title>
		<link>http://www.bdcsoftware.com/five-years-with-firebird/</link>
		<comments>http://www.bdcsoftware.com/five-years-with-firebird/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 23:35:19 +0000</pubDate>
		<dc:creator>raf</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://www.bdcsoftware.com/?p=155</guid>
		<description><![CDATA[
It&#8217;s unbelievable, but the Interbase with VB article has been written over five years ago. Over the years the article has received hundreds of thousands of hits and I hope we have left a mark with the developer community. This little write-up is intended as a follow-up or more like a status update on our [...]]]></description>
			<content:encoded><![CDATA[<p>
It&rsquo;s unbelievable, but the Interbase with VB article has been written over five years ago. Over the years the article has received hundreds of thousands of hits and I hope we have left a mark with the developer community. This little write-up is intended as a follow-up or more like a status update on our experience with Interbase/Firebird.
</p>
<p>
Even though the original article is fairly old by internet/development standards, most of the facts still stand. However, life never stands still, especially not for small agile software companies. By the end of 2001, Borland has seized any future development on the open-sourced version of Interbase. Fortunately a group of amazing developers has picked up the slack and forked the code base and in winter 2002 we have switched to Firebird 1.0 the &ldquo;true&rdquo; open source Interbase and the following year to Firebird 1.5.With close to 1000 deployments on various desktop and server configurations and thousands of gigabytes of data spread across all the databases, I think we can consider ourselves as seasoned Firebird users/developers. </p>
<p>
But, as with any technology, we had our share of challenge and success stories. Following are a few items what to look for and what to look out for. Let&rsquo;s start with the issues as these are most of the time the determining factor when it comes to adoption of new technology:</p>
<h3><span style="font-weight: bold">The Issues</span></h3>
<p>Firebird is not very forgiving when it comes to sloppy SQL syntax. Things that you can get away with in SQL Server, will kill the db performance in Firebird. For instance: </p>
<p><span style="font-style: italic; color: #9999cc">Select * from SomeTable where id in (Select some_id from SomeOtherTable)</span></p>
<p>If  the subselect should return a lot of records, the performance will be abysmal. Fortunately if you think outside of the box, there is always a workaround. In this case we could use a selectable stored proc to do an inner join on like this:</p>
<p><span style="font-style: italic; color: #9999cc">Select * from SomeTable inner join SelectableStoredProcedure(Params) on (someid = stored_proc_param)</span></p>
<p>Another issue that we have run into a few times is the high bandwidth requirement when transferring large blob datasets over the Ethernet. Essentially, when performing a query that returns a lot of data (lets say 100 MB) to the client, Firebird will max out the Ethernet bandwidth on a 100 Mbps switch very quickly without even making the hard drives work. SQL Server performs much better in this instance.</p>
<p>One feature that we sorely miss is the cross database joins that are easily done in SQL server. There are workarounds in Firebird (like defining an external table) but it&rsquo;s not the same. Hopefully, this feature will be added to FB 2.0.</p>
<h3><span style="font-weight: bold">The Awesome</span></h3>
<p>Enough of the issues, lets cover the exciting items, things that have made our lives easy:</p>
<p>The deployment as part of a custom setup is a breeze. With all our deployments  we have had only 3 problem installations. One was caused by a faulty Ethernet card and the other two on Windows ME. I think this metric speaks for itself. In contrast, we are supporting an outside company with MSDE deployments. The failure rate is an astonishing 25% for MSDE deployments in uncontrolled environments. Most of the time these are issues that can be resolved, but the cost of support is very high.</p>
<p>Mentioned before, selectable stored procedures. The power of this feature becomes evident when you can do an inner or outer join between a table and a stored procedure. In addition, stored procedures work &ldquo;internally&rdquo; similar to cursors (there is a loop inside the stored proc) where additional programming logic can be embedded.</p>
<p>Firebird also works well in many environments. Currently we have a .NET project with Firebird deployment on Win2K3, VB6 projects and even Firebird running with Ruby on Rails on a Linux host. </p>
<p>Hopefully this little status update will be useful to somebody. What&rsquo;s important that after five years, we are still sticking with Firebird and there is no change in sight&hellip;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bdcsoftware.com/five-years-with-firebird/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interbase and ADO tutorial</title>
		<link>http://www.bdcsoftware.com/interbase-and-ado-tutorial/</link>
		<comments>http://www.bdcsoftware.com/interbase-and-ado-tutorial/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 23:01:50 +0000</pubDate>
		<dc:creator>raf</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://www.bdcsoftware.com/?p=151</guid>
		<description><![CDATA[Has anybody ever wondered if there is an Open Source alternative to SQL Server or Access databases? Well, I have, and I found Interbase. Interbase is a Client/Server database from Borland. It is Open Source. It runs on Windows, Linux and bunch of other *nix platforms. It has a very small memory footprint and it [...]]]></description>
			<content:encoded><![CDATA[<p>Has anybody ever wondered if there is an Open Source alternative to SQL Server or Access databases? Well, I have, and I found Interbase. Interbase is a Client/Server database from Borland. It is Open Source. It runs on Windows, Linux and bunch of other *nix platforms. It has a very small memory footprint and it is relatively fast.</p>
<p>
It will also support large database files (larger then 2 gig. I know a guy that has a 300 Gig database up and running)
</p>
<p>
Anyhow, in this article I will describe the issues and the necessary tools to get you up and running with Interbase.
</p>
<p>
First let me tell you about the benefits of Interbase: </p>
<ol>
<li>Open Source</li>
<li>Fast</li>
<li>Small size</li>
<li>Very easy distribution (scripts for Wise or InstallShield are available)</li>
<li>Works ADO</li>
<li>Works with ODBC</li>
<li>Awesome transaction management (readers never block writers and vice versa)</li>
<li>Multiple platform support (Linux/Unix)</li>
<li>Superb support for BLOB fields (Images and memo fields)</li>
<li>Support for Arrays (you can store Arrays in individual fields)</li>
</ol>
<p>
For starters you need to get the server and client software. You can get the original Open Source version (Source and Binaries) from Borland at:
</p>
<p>
<a href="http://www.borland.com/devsupport/interbase/opensource/">http://www.borland.com/devsupport/interbase/opensource/ <br />
     </a>or get it a modified version (Firebird) from: <br />
     <a href="http://www.ibphoenix.com/ibp_download.html">http://www.ibphoenix.com/ibp_download.html </a>
</p>
<p>
Download and install the server and client binaries. The Interbase server ships with a ODBC driver, but I hate ODBC and use ADO/OleDB on a day to day basis. So I had to find an OleDB driver for Interbase. Luckily there are numerous available. You can find a links to download sites on this site:
</p>
<p>
<a href="http://www.interbase2000.org/tools_conn.htm%20">http://www.interbase2000.org/tools_conn.htm </a>
</p>
<p>
I opted for the IBProvider from <a href="http://www.lcpi.lipetsk.ru/prog/eng/index.html">http://www.lcpi.lipetsk.ru/prog/eng/index.html </a> because they had some VB samples of how to use the provider with ADO. The version that you can download is an Evaluation for 30 days. If you want a completely free OleDB provider then use: <a href="http://www.oledb.net/?Page=FAQ">Http://www.oledb.net/?Page=FAQ </a>. However, all my sample code is tested with IBProvider only.
</p>
<p>
Once you have downloaded and installed all the files, you are ready for development. IB (Interbase) ships with a sample database called employee.gdb. We will use this database as an example. (You can find it in &#8216;C:Program FilesBorlandInterBaseexamplesDatabase&#8217; , provided you installed the server in the default location). Anyhow, lets start with the basics:
</p>
<p>
<strong>Connecting to Interbase </strong><br />
   Lets establish a connection to the database. A sample connection:
</p>
<p>
<em>Dim adoConn As New ADODB.Connection </em>
</p>
<p>
<em> adoConn.ConnectionString = &quot;provider=LCPI.IBProvider;data source=localhost:C:Interbase DBsEmployee.gdb;ctype=win1251;user id=SYSDBA;password=masterkey&quot; </em>
</p>
<p>
<em> adoConn.Open </em>
</p>
<p>
<br />
   Ok, here are a few things to consider: <br />
 Default user name and password (like SA in SQLServer) are SYSDBA and masterkey (case sensitive). The &#8216;data source&#8217; parameter has a following syntax: IP Address:file location on the remote system . If you installed the server on your development machine then use localhost or your IP. If you installed it on a remote machine then use the IP Address of the machine. The file location is a bit weird. It is local to the server and you can&#8217;t use UNC paths.
</p>
<p>
Once the connection is open, we can start working with the database.
</p>
<p>
<strong>Working with an Interbase database </strong><br />
 For the most part, working with Interbase is as easy as working with SQL Server or Access. However there are a few things to consider:
</p>
<p>
For one, Interbase uses dialects, basically it&#8217;s the SQL syntax that you issue your commands to the database. IB 6.0 can use Dialect 1 (legacy) and Dialect 3. The sample databases are in written in Dialect 1. If you decide to use Dialect 3 (as I have), you will notice some weird behavior. If your database has lower case table and field names, you will have to surround them with double quotes. For instance: Select &quot;CompanyName&quot;, &quot;Address&quot; from &quot;tblCustomers&quot;. Needless to say this will create havoc with VB programmers J. One workaround is to use caps for table and field names. (Btw, don&#8217;t ask me why this is the way it is.) For Instance: SELECT COMPAN_YNAME, ADDRESS FROM TBLCUSTOMERS.
</p>
<p>
The other issue that I have found is: you cannot use adCmdStoredProc as your command type. Workaround for this: use adCmdText. But more to this later.
</p>
<p>
Ok, so how would we get some data in and out of our database? Well, you can use your normal recordset object to execute a SQL statement or you can use stored procedures.
</p>
<p>
Here is a sample of a simple select statement:
</p>
<p>
<em>Dim rst As New Recordset </p>
<p>   rst.Source = &quot;SELECT CUSTOMER.CONTACT_FIRST, &quot; &amp; _ <br />
 &quot;CUSTOMER.CONTACT_LAST, CUSTOMER.COUNTRY &quot; &amp; _ <br />
 &quot;FROM CUSTOMER&quot; </p>
<p>   rst.ActiveConnection = adoConn <br />
   adoConn.BeginTrans <br />
   rst.Open <br />
   adoConn.CommitTrans </em>
</p>
<p>
And here is a simple stored procedure execution:
</p>
<p>
<em>Dim rst As New Recordset <br />
   Dim cmd As New ADODB.Command </em>
</p>
<p>
<em> adoConn.Open </p>
<p>   With cmd <br />
   .ActiveConnection = adoConn <br />
   .CommandText = &quot;Select * FROM DEPT_BUDGET (100)&quot; <br />
   End With </em>
</p>
<p>
<em> adoConn.BeginTrans <br />
   Set rst = cmd.Execute <br />
   adoConn.CommitTrans </em>
</p>
<p>
<br />
 Notice that if your stored procedure returns any rows, you have to use the &#8216;SELECT * FROM stored procedure name&#8217; syntax. If your procedure does not return any records, you can use &#8216;EXECUTE stored procedure name&#8217;.
</p>
<p>
Also, the way you pass parameters in and out of the procedure is a bit peculiar. Lets say you have an insert stored procedure that will accept 3 parameters. To pass those parameters you can use inline syntax: For instance, &#8216;execute procedure PROC_INSERT_TBLCUSTOMERS (comma delimited parameter values)&#8217; or you can use this syntax:
</p>
<p>
<em>With cmd <br />
   .ActiveConnection = adoConn <br />
   .CommandText = &quot; execute procedure PROC_INSERT_TBLCUSTOMERS (?,?,?)&quot; <br />
   End With </em>
</p>
<p>
<em>adoConn.BeginTrans <br />
   cmd(0) = parameter value <br />
   cmd(1) = parameter value <br />
   cmd(2) = parameter value <br />
   cmd.Execute <br />
   adoConn.CommitTrans </em>
</p>
<p>
<br />
 Anyhow, these are the basics. If you guys are interested in Interbase, I will write a 2nd part of the tutorial that will cover some advanced features like working with Images, Arrays, UDF functions and tools for Interbase. For now take a look at the sample code for this tutorial, and take a look at the sample databases that are provided by Borland.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bdcsoftware.com/interbase-and-ado-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
