Guest User

Untitled

a guest
Sep 25th, 2014
241
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ALTER PROCEDURE [dbo].[RoutePlan_Save]
  2.  
  3. (
  4.     @RoutePlanId int,
  5.     @FormId int,
  6.     @UserId int,
  7.     @Rank int,
  8.     @RoutePlanStatusId int = NULL,
  9.     @StatusDate datetime = NULL,
  10.     @Notes varchar(500) = NULL,
  11.     @IsStrict bit,
  12.     @RoutePlanResponsibilityId int,
  13.     @IsPostApproval bit,
  14.     @ProcessedByUserId int = NULL,
  15.     @Deleted bit,
  16.     @CreatedById int = NULL,
  17.     @ModifiedById int = NULL
  18. )
  19. AS
  20. BEGIN
  21.  
  22.     SET NOCOUNT ON
  23.  
  24.     DECLARE @PrivateErrorVar int
  25.     DECLARE @localRoutePlanId int
  26.     DECLARE @localFormId int
  27.     DECLARE @localUserId int
  28.     DECLARE @localRank int
  29.     DECLARE @localRoutePlanStatusId int
  30.     DECLARE @localStatusDate datetime
  31.     DECLARE @localNotes varchar(500)
  32.     DECLARE @localIsStrict bit
  33.     DECLARE @localRoutePlanResponsibilityId int
  34.     DECLARE @localIsPostApproval bit
  35.     DECLARE @localProcessedByUserId int
  36.     DECLARE @localDeleted bit
  37.     DECLARE @localCreatedById int
  38.     DECLARE @localModifiedById int
  39.     SET @localRoutePlanId = @RoutePlanId
  40.     SET @localFormId = @FormId
  41.     SET @localUserId = @UserId
  42.     SET @localRank = @Rank
  43.     SET @localRoutePlanStatusId = @RoutePlanStatusId
  44.     SET @localStatusDate = @StatusDate
  45.     SET @localNotes = @Notes
  46.     SET @localIsStrict = @IsStrict
  47.     SET @localRoutePlanResponsibilityId = @RoutePlanResponsibilityId
  48.     SET @localIsPostApproval = @IsPostApproval
  49.     SET @localProcessedByUserId = @ProcessedByUserId
  50.     SET @localDeleted = @Deleted
  51.     SET @localCreatedById = @CreatedById
  52.     SET @localModifiedById = @ModifiedById
  53.  
  54.     IF EXISTS(SELECT [RoutePlan].[RoutePlanId] FROM [RoutePlan] WHERE
  55.             ([RoutePlan].[RoutePlanId] = @localRoutePlanId))
  56.     BEGIN
  57.    
  58.    
  59.         UPDATE [RoutePlan]
  60.         SET
  61.             [RoutePlan].[FormId] = @localFormId,
  62.             [RoutePlan].[UserId] = @localUserId,
  63.             [RoutePlan].[Rank] = @localRank,
  64.             [RoutePlan].[RoutePlanStatusId] = @localRoutePlanStatusId,
  65.             [RoutePlan].[StatusDate] = @localStatusDate,
  66.             [RoutePlan].[Notes] = @localNotes,
  67.             [RoutePlan].[IsStrict] = @localIsStrict,
  68.             [RoutePlan].[RoutePlanResponsibilityId] = @localRoutePlanResponsibilityId,
  69.             [RoutePlan].[IsPostApproval] = @localIsPostApproval,
  70.             [RoutePlan].[ProcessedByUserId] = @localProcessedByUserId,
  71.             [RoutePlan].[Deleted] = @localDeleted,
  72.             [RoutePlan].[ModifiedById] = @localModifiedById,
  73.             [RoutePlan].[ModifiedDate] = GETDATE()
  74.         WHERE
  75.         [RoutePlan].[RoutePlanId] = @localRoutePlanId
  76.  
  77.         SET @PrivateErrorVar = @@Error
  78.  
  79.    
  80.     END
  81.     ELSE
  82.     BEGIN
  83.    
  84.         INSERT
  85.         INTO [RoutePlan]
  86.         (
  87.             [RoutePlan].[FormId],
  88.             [RoutePlan].[UserId],
  89.             [RoutePlan].[Rank],
  90.             [RoutePlan].[RoutePlanStatusId],
  91.             [RoutePlan].[StatusDate],
  92.             [RoutePlan].[Notes],
  93.             [RoutePlan].[IsStrict],
  94.             [RoutePlan].[RoutePlanResponsibilityId],
  95.             [RoutePlan].[IsPostApproval],
  96.             [RoutePlan].[ProcessedByUserId],
  97.             [RoutePlan].[Deleted],
  98.             [RoutePlan].[CreatedById],
  99.             [RoutePlan].[CreatedDate]
  100.         )
  101.         VALUES
  102.         (
  103.             @localFormId,
  104.             @localUserId,
  105.             @localRank,
  106.             @localRoutePlanStatusId,
  107.             @localStatusDate,
  108.             @localNotes,
  109.             @localIsStrict,
  110.             @localRoutePlanResponsibilityId,
  111.             @localIsPostApproval,
  112.             @localProcessedByUserId,
  113.             @localDeleted,
  114.             @localCreatedById,
  115.             GETDATE()
  116.         )
  117.  
  118.         SET @PrivateErrorVar = @@Error
  119.  
  120.         SELECT @localRoutePlanId = SCOPE_IDENTITY()
  121.  
  122.  
  123.     END
  124.     --*** Return the PK
  125.     SELECT @localRoutePlanId
  126.     RETURN @PrivateErrorVar
  127. END
RAW Paste Data