Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. create TRIGGER TR_U_F_ADDRESS ON ADDRESS
  2. after update as
  3. begin
  4. -- редактирование второго и последующих адресов гражданина
  5. declare @isn_citizen int,
  6. @i_zipcode varchar(12), @d_zipcode varchar(12),
  7. @i_addres varchar(2000), @d_addres varchar(2000),
  8. @comm varchar(255);
  9.  
  10. declare cur cursor local for
  11. select cit.isn_citizen,
  12. isnull(i.addres, ''), isnull(d.addres, ''),
  13. isnull(i.zipcode, ''), isnull(d.zipcode, '')
  14. from inserted i
  15. join deleted d on i.isn_address = d.isn_address
  16. join citizen cit on i.isn_owner = cit.isn_citizen
  17. where i.ORDERNUM > 1 and
  18. (
  19. isnull(i.addres, '') <> isnull(d.addres, '') or
  20. isnull(i.zipcode, '') <> isnull(d.zipcode, '')
  21. )
  22. open cur
  23. while 1 = 1 begin
  24. fetch next from cur into @isn_citizen,
  25. @i_addres, @d_addres,
  26. @i_zipcode, @d_zipcode;
  27. if @@fetch_status <> 0 break
  28.  
  29. if ISNULL(@i_addres, '') <> ISNULL(@d_addres, '') begin
  30. set @comm = substring('''Адрес'' было = ' + isnull(@d_addres , '') + ', cтало = ' + isnull(@i_addres , ''), 1, 255)
  31. execute pprt6_write_prot 'CUUBAS', @isn_citizen, @comm
  32. end
  33.  
  34. if ISNULL(@i_zipcode, '') <> ISNULL(@d_zipcode, '') begin
  35. set @comm = substring('''Почтовый индекс'' было = ' + isnull(@d_zipcode , '') + ', cтало = ' + isnull(@i_zipcode , ''), 1, 255)
  36. execute pprt6_write_prot 'CUUBAS', @isn_citizen, @comm
  37. end
  38. end
  39. close cur deallocate cur
  40. end
  41. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement