if (exists (select * from sys.objects where name = 'proc_initialization_jz'))
drop proc proc_initialization_jz
go
create proc proc_initialization_jz
as
BEGIN
DECLARE
@A0100 varchar(30),
@A91A2 varchar(30),
@A91AA varchar(30),
@A91A9 varchar(30),
@A91A4 varchar(300),
@syncKey varchar(100),
@MaxI9999 integer,
@I9999 integer,
@jz_str varchar(300)
DECLARE c_jz CURSOR FOR SELECT distinct A0100 FROM USRA91 WHERE A91A7='0';
OPEN c_jz;
FETCH NEXT FROM c_jz INTO @A0100
WHILE (@@FETCH_STATUS = 0)
BEGIN
SET @jz_str=''
DECLARE c_jz1 CURSOR FOR SELECT A91A2,A91AA,A91A9,A91A4 FROM USRA91 WHERE A0100=@A0100 and A91A7='0' order by i9999;
OPEN c_jz1;
FETCH NEXT FROM c_jz1 INTO @A91A2, @A91AA,@A91A9,@A91A4
WHILE (@@FETCH_STATUS = 0)
BEGIN
SELECT @syncKey = GUIDKEY FROM UsrA01 WHERE A0100=@A0100
IF LEN(@jz_str) >0 AND ISNULL(@A91A2,'') <>'' AND ISNULL(@A91AA,'')<>'' AND ISNULL(@A91A9,'')<>'' AND ISNULL(@A91A4,'')<>''
SET @jz_str = @jz_str + ';' +@A91A2+ '@'+ @A91AA + '@' + @A91A9 + '@' + @A91A4
ELSE IF ISNULL(@A91A2,'') <>'' AND ISNULL(@A91AA,'')<>'' AND ISNULL(@A91A9,'')<>'' AND ISNULL(@A91A4,'')<>''
SET @jz_str = @A91A2+ '@'+ @A91AA + '@' + @A91A9 + '@' + @A91A4
FETCH NEXT FROM c_jz1 INTO @A91A2, @A91AA,@A91A9,@A91A4
END;
CLOSE c_jz1;
DEALLOCATE c_jz1;
IF EXISTS(SELECT 1 FROM t_hr_view WHERE t_hr_view.UNIQUE_ID=@syncKey)
BEGIN
UPDATE t_hr_view SET H01ST = @jz_str,sdate = GETDATE() WHERE t_hr_view.UNIQUE_ID=@syncKey;
END;
FETCH NEXT FROM c_jz INTO @A0100
END;
CLOSE c_jz;
DEALLOCATE c_jz;
END