USE DYNAMICS
set nocount on
declare @Userid char(15)
declare cDispHP cursor for
select A.USERID
from SY01400 A left join SY08000 B on A.USERID = B.USERID
where B.USERID is null or B.DISPHP <> 0
open cDispHP
while 1 = 1
begin
fetch next from cDispHP into @Userid
if @@FETCH_STATUS <> 0 begin
close cDispHP
deallocate cDispHP
break
end
if exists (select DISPHP from DYNAMICS.dbo.SY08000 where USERID = @Userid)
begin
print 'adjusting ' + @Userid
update DYNAMICS.dbo.SY08000
set DISPHP = 0
where USERID = @Userid
end
else begin
print 'adding ' + @Userid
insert DYNAMICS.dbo.SY08000 ( USERID, DISPHP, REFRSHHP, User_Role )
values ( @Userid, 0, 0, 121 )
end
end /* while */
set nocount off
No comments:
Post a Comment