Wednesday, January 05, 2011

SQL Framework

Introduction
Developers who have experienced in large application development know the necessities of framework. In this regards, more experience developer like Team Lead, Technical Lead and Project Manager up to CTO have high respect of it. They know from their experience that large application should develop in very organized way so that newly assigned developers take tiny time to adopt the development structure behind the application and take less costly man hour form Team Lead or other senior developers. They also know that maintenance will be easy and cost effective after development has been completed for the application.

Background
Apart from this I will be going through developing a SQL Framework. I will show the necessity of it with demonstration.

Let’s Get Started
Open SQL Management Studio
Say you are working in a large software company for a big project and will take long time. You have many programmers working under you in this project. Sometimes programmers are switching from your software company and replace by newly join programmers. So far this is a big project so underlining database size will be accordingly. Say, you have assigned a task to a programmer to create a store procedure for data insertion with proper validation and other necessary command in store procedure.
The bellow procedure has been created by the programmer as his assigned task.

CREATE PROCEDURE [dbo].[Customer_Set]

@Name as varchar(50),
@Address as varchar(250),  
@Mobile as varchar(50)
AS
BEGIN

SET NOCOUNT ON
--Validation
IF @Name IS NULL
BEGIN
RAISERROR ('Name cannot be empty.',16,1)
END
IF LEN(@Name)<3
BEGIN
RAISERROR ('Name cannot be less than 3 characters.',16,1)
END
--Data Insertion
BEGIN TRY
INSERT INTO [dbo].[Customer]
([Name]
,[Address]
,[Mobile])
VALUES
(@Name
,@Address
,@Mobile)
END TRY
BEGIN CATCH
RETURN (0)
END CATCH
 RETURN (1)
END

Read more: Codeproject