Advertisement
Ruslan_Rayanov

fm_human_saveItem

Oct 10th, 2020
669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.13 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[fm_human_saveItem]
  2.     @username nvarchar(256),
  3.     @itemID int,
  4.     @parameters ExtendedDictionaryParameter readonly
  5. AS
  6. BEGIN
  7.     if (@itemID>0) begin
  8.         -- извлекаем параметры формы из коллекции
  9.         declare @pfio nvarchar(max)
  10.         select @pfio = value from @parameters where [Key]='fio'
  11.         declare @pphone nvarchar(max)
  12.         select @pphone = value from @parameters where [Key]='phone'
  13.         declare @pdepID int
  14.         select @pdepID = try_cast(value as int) from @parameters where [Key]='depID'
  15.         declare @pfreelancer bit
  16.         select @pfreelancer = try_cast(value as bit) from @parameters where [Key]='freelancer'
  17.        
  18.         -- обновляем сотрудника
  19.         update hr_humans
  20.         set fio = @pfio,
  21.             phone = @pphone,
  22.             depID = @pdepID,
  23.             freelancer = @pfreelancer
  24.         where id = @itemID
  25.        
  26.         --SELECT 1 выдаем результат        
  27.         select 1 Result, 'Сохранено' Msg
  28.         return
  29.     end
  30.     select 0 Result, 'Неверные параметры' Msg
  31. END
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement