'T' and io_batch_id = '@{batchNo}' ) ]]> 'T' and io_batch_id = '@{batchNo}' ) temp_position on md_position.id = temp_position.position_id and md_position.category_code = 'Sales' set md_position.company_id = temp_position.company_id, md_position.bu_id = temp_position.bu_id, md_position.parent_id = temp_position.parent_id, md_position.code = temp_position.position_code, md_position.name = temp_position.position_name, md_position.type_code = temp_position.type_code, md_position.type_name = temp_position.type_name, md_position.remark = temp_position.remark, md_position.region = temp_position.region, md_position.index_no = temp_position.index_no ]]> 'T' and ifnull(parent_code, '') <> '' and not exists (select 1 from md_position where temp_position.parent_code = md_position.code ) ]]> 'T' and not exists (select 1 from md_position where temp_position.position_code = md_position.code ) ]]> 'T' ]]> 'T' ]]> 'T' ]]> 'T' ]]> 'T' ]]> 'T' ]]> 'T' ]]> 'T' and not exists (select 1 from md_employee where temp_position.remark = md_employee.name ) ]]> zone then @pids := 2 when @name = zone then @pids := @pids + 1 end index_num, case when @name <> zone then @name := zone end zonename from (select zone, type_code, code, short_name from temp_position where department_id = 'Dep-sales' and type_code not in ('Country', 'Region') order by zone, type_code desc, short_name, code) md_position, (select @pids := 1, @name := 2) math_common group by zone, type_code, short_name, code order by zone, type_code desc, short_name, code) tmp_position on temp_position.position_code = tmp_position.code set temp_position.index_no = index_num where ids = '@{ids}' ]]> '' ]]> '' ]]>