declare cur02 cursor local static scroll for
select gend_option,gend_name
from gend_det
where gend_gen = @ipq_part_3
and (rtrim(gend_char1) = '' or (charindex(rtrim(@ipq_cx) + ',', rtrim(gend_char1) + ',')) > 0)
open cur02
fetch first from cur02 into @tmp_option,@tmp_name
while @@fetch_status = 0
begin
select @ipq_line = @ipq_line + 10
select @sql='insert into #rst(r_part,r_option,r_require,r_rmks) (select '''+rtrim(@ipq_part)+''','''+rtrim(@tmp_option)+''',a'+rtrim(@tmp_option)+'a, r+'' ''+x+str(y) from t_ipqc$ where l='''+rtrim(@ipq_part)+''')'
exec(@sql)
select @temp_require = r_require from #rst where r_part=@ipq_part and r_option=@tmp_option
select @temp_rmks = r_rmks from #rst where r_part=@ipq_part and r_option=@tmp_option
insert into ipqd_det (ipqd_nbr,ipqd_line,ipqd_method,ipqd_project,ipqd_rst1,ipqd_rmks)
values(@ipq_nbr,@ipq_line,@tmp_name,'',isnull(@temp_require,''),isnull(@temp_rmks,''))
fetch next from cur02 into @tmp_option,@tmp_name
end
close cur02
deallocate cur02
select gend_option,gend_name
from gend_det
where gend_gen = @ipq_part_3
and (rtrim(gend_char1) = '' or (charindex(rtrim(@ipq_cx) + ',', rtrim(gend_char1) + ',')) > 0)
open cur02
fetch first from cur02 into @tmp_option,@tmp_name
while @@fetch_status = 0
begin
select @ipq_line = @ipq_line + 10
select @sql='insert into #rst(r_part,r_option,r_require,r_rmks) (select '''+rtrim(@ipq_part)+''','''+rtrim(@tmp_option)+''',a'+rtrim(@tmp_option)+'a, r+'' ''+x+str(y) from t_ipqc$ where l='''+rtrim(@ipq_part)+''')'
exec(@sql)
select @temp_require = r_require from #rst where r_part=@ipq_part and r_option=@tmp_option
select @temp_rmks = r_rmks from #rst where r_part=@ipq_part and r_option=@tmp_option
insert into ipqd_det (ipqd_nbr,ipqd_line,ipqd_method,ipqd_project,ipqd_rst1,ipqd_rmks)
values(@ipq_nbr,@ipq_line,@tmp_name,'',isnull(@temp_require,''),isnull(@temp_rmks,''))
fetch next from cur02 into @tmp_option,@tmp_name
end
close cur02
deallocate cur02