Академический Документы
Профессиональный Документы
Культура Документы
AS DECLARE @ReturnValue int IF (@id IS NULL) -- New Item BEGIN INSERT INTO EmailAddress ( Email, EmailType, ContactPersonId ) VALUES ( @email, @emailType, @contactPersonId ) SELECT @ReturnValue = SCOPE_IDENTITY() END ELSE BEGIN UPDATE EmailAddress SET Email = @email, EmailType = @emailType, ContactPersonId = @contactPersonId WHERE Id = @id SELECT @ReturnValue = @id END IF (@@ERROR != 0) BEGIN RETURN -1 END ELSE BEGIN RETURN @ReturnValue END
GO
But generally, I keep stored procedures as simple as possible. Shoving a load of logic in the things to determine the action that should be taken based on inputs is, to my mind, a "bad thing", and is more likely to lead to maintenance problems. Would she also say that you have too many methods in your code-behind/BLL? Perhaps she would recommend that you combine all those as well?