Advertisement
hecrus

demo1 fastCreate

Oct 17th, 2020
1,181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.82 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[crud_tst-customers_fastCreate]
  2.     @filters CRUDFilterParameter READONLY,
  3.     @text nvarchar(256),
  4.     @username nvarchar(32)
  5. AS
  6. BEGIN
  7.     -- создание сущности в таблице по 1 полю @text
  8.  
  9.    
  10.     -- извлечение параметров из URL
  11.     --declare @filterItemID int
  12.     --select @filterItemID = try_cast(Value as int) from @filters where [Key] = 'itemID'
  13.    
  14.    
  15.     -- проверки
  16.     declare @id int
  17.     select @id = id from tst_customers where name = @text or fio = @text
  18.     if(@id>0) begin
  19.         select 'Такой заказчик уже существует!' Msg, 0 Result
  20.         return
  21.     end
  22.  
  23.  
  24.     -- добавление элемента в таблицу
  25.     insert into tst_customers(name, fio)
  26.     values(@text, @text )
  27.     select 'Заказчик создан' Msg, 1 Result
  28.  
  29. END
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement