Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create TRIGGER TR_U_F_ADDRESS ON ADDRESS
- after update as
- begin
- -- редактирование второго и последующих адресов гражданина
- declare @isn_citizen int,
- @i_zipcode varchar(12), @d_zipcode varchar(12),
- @i_addres varchar(2000), @d_addres varchar(2000),
- @comm varchar(255);
- declare cur cursor local for
- select cit.isn_citizen,
- isnull(i.addres, ''), isnull(d.addres, ''),
- isnull(i.zipcode, ''), isnull(d.zipcode, '')
- from inserted i
- join deleted d on i.isn_address = d.isn_address
- join citizen cit on i.isn_owner = cit.isn_citizen
- where i.ORDERNUM > 1 and
- (
- isnull(i.addres, '') <> isnull(d.addres, '') or
- isnull(i.zipcode, '') <> isnull(d.zipcode, '')
- )
- open cur
- while 1 = 1 begin
- fetch next from cur into @isn_citizen,
- @i_addres, @d_addres,
- @i_zipcode, @d_zipcode;
- if @@fetch_status <> 0 break
- if ISNULL(@i_addres, '') <> ISNULL(@d_addres, '') begin
- set @comm = substring('''Адрес'' было = ' + isnull(@d_addres , '') + ', cтало = ' + isnull(@i_addres , ''), 1, 255)
- execute pprt6_write_prot 'CUUBAS', @isn_citizen, @comm
- end
- if ISNULL(@i_zipcode, '') <> ISNULL(@d_zipcode, '') begin
- set @comm = substring('''Почтовый индекс'' было = ' + isnull(@d_zipcode , '') + ', cтало = ' + isnull(@i_zipcode , ''), 1, 255)
- execute pprt6_write_prot 'CUUBAS', @isn_citizen, @comm
- end
- end
- close cur deallocate cur
- end
- /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement