AddUpdateDocument_Category

Code:-

CREATE PROCEDURE [dbo].[Add_Update_Document_Category]
	(
		@Category_Type varchar(25),
		@Category_Name varchar(50),
		@Category_Comment varchar(100) = '',
		@Field_Name varchar(50),
		@Restriction_Type char(10),
		@Restriction_Value varchar(200)
	)
AS
	
	IF EXISTS(SELECT 'A' FROM dbo.[Document Categories]
	            WHERE [Category Type] = @Category_type
	              AND [Category Name] = @Category_Name)
	              
	       UPDATE [Document Categories]
	          SET Description = @Category_Comment
	          WHERE [Category Type] = @Category_type
	              AND [Category Name] = @Category_Name
	              
	ELSE
	
	       INSERT INTO [Document Categories] VALUES 
	         (@Category_Type,
	          @Category_Name, 
	          @Category_Comment)
	          
	-- Update or add to the automated document categorisation
	IF EXISTS(SELECT 'A' FROM dbo.[Automatic Document Categorisation]
	            WHERE [Category Type] = @Category_type
	              AND [Category Name] = @Category_Name)          
	          
	      UPDATE dbo.[Automatic Document Categorisation]
	         SET [Document Field Name] = @Field_Name,
	             [Restriction Type] = @Restriction_Type,
	             [Restriction Value] = @Restriction_Value
	       WHERE [Category Type] = @Category_type
	              AND [Category Name] = @Category_Name
	              
	 ELSE
	 
	     INSERT INTO dbo.[Automatic Document Categorisation] VALUES
	       (
	       @Category_Type,
	       @Category_Name,
	       @Field_Name,
	       @Restriction_Type,
	       @Restriction_Value
	       )
	             
	
	
	RETURN 

Last edited Oct 21, 2009 at 8:24 AM by Merrion, version 2

Comments

No comments yet.