hecrus

CRUD deleteItem

Oct 10th, 2020
683
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE PROCEDURE [dbo].[crud_deps_deleteItem]
  2.     @itemID int,
  3.     @username nvarchar(32)
  4. AS
  5.     -- удаление строки таблицы
  6.     SET NOCOUNT off ;
  7.    
  8.      -- проверки перед удалением
  9.      declare @count int
  10.      select @count = count(*) from hr_humans
  11.      where depID = @itemID
  12.      
  13.      if(@count>0) begin
  14.         select 'На поле есть ссылки в humans ('+cast(@count as nvarchar)+' шт.)' Msg, 0 Result
  15.         return
  16.      end  
  17.    
  18.     -- удаление элемента
  19.     delete from hr_departments where id = @itemID
  20.    
  21.     if (@@ROWCOUNT > 0) begin
  22.         select '' Msg, 1 Result
  23.     end else begin
  24.         select 'Запись не удалилась из базы' Msg, 0 Result
  25.     end
  26.  
  27.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×