| DotNetFirebird Using Firebird SQL in .NET. |
|
Home
Features
Download
Documentation
FAQ
Tools and Code
About
Blog
|
Sunday, January 09, 2005
Using Stored Procedures for Data AccessWhen I started using Firebird I was calling raw SQL from the code and only when there was no other choice I was calling a stored procedure. When there was a too complicated SELECT command I saved it as a view. Now I am more and more relying on stored procedures. The Firebird ADO.NET provider makes this easier by providing a Microsoft-SQL-style stored procedure calling: FbCommand cmd = new FbCommand("SP_INSERTDOCUMENT", new FbConnection(this.ConnectionString));
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@guid", guid);
cmd.Parameters.Add("@parent", parent);
...
It makes the .NET code much easier to read. It has also other advantages:
Comments:
It is observed through my performance benchmarks that store procedures take more CPU and time to execute as compared to adhoc SQL queries. I am using simple Create, read, update and delete queries and stored procedures. I am using embedded firebird database in my application and .net firebird wrapper to make such calls. Is this behavior expected or is it something missing in my approach.
I believe in other database systems the behavior you observed is expected. I've read several other places that SQL optimization (done internally by the database) usually outperforms handwritten code.
Blog comments are closed.
Previous
Archives
Copyright © 2005 - 2007 DotNetFirebird |