0_update_data_relation_appendix.sql 1.1 KB

12345678910111213141516171819202122232425
  1. DROP PROCEDURE IF EXISTS update_data_relation_appendix;
  2. DELIMITER $$
  3. CREATE PROCEDURE update_data_relation_appendix(IN n INT,
  4. IN mas_url VARCHAR(200))
  5. BEGIN
  6. SET @citySuffix = concat('_city', n);
  7. SET @prevDocId = ifnull((SELECT prev_id from data_migration_log where table_name = 'wcmdocument'), 0);
  8. SET @prevTableInfoId = ifnull((SELECT prev_id from data_migration_log where table_name = 'xwcmtableinfo'), 0);
  9. SET @wcmdocument_offset_num = ifnull((SELECT max(offset_num) FROM data_migration_offset WHERE table_name = 'wcmdocument'), 0);
  10. SET @docIdOffset = @wcmdocument_offset_num;
  11. SET @appendix_offset_num = ifnull((SELECT max(offset_num) FROM data_migration_offset WHERE table_name = 'xwcmmaterial'), 0);
  12. SET @appendixIdOffset = @appendix_offset_num;
  13. call update_data_relation_appendix_1(@prevDocId, @appendixIdOffset, @docIdOffset);
  14. call update_data_relation_appendix_2(@citySuffix, @prevTableInfoId, @prevDocId);
  15. UPDATE trs_hycloud_iip.wcmappendix SET APPFILE = CONCAT(mas_url, AppFromId) WHERE APPFLAG = 90 AND APPENDIXID > @appendixIdOffset;
  16. END $$
  17. DELIMITER ;