productmatchresults.sql 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. -- ----------------------------
  2. -- Triggers structure for table productmatchresults
  3. -- ----------------------------
  4. DROP TRIGGER IF EXISTS `sync$productmatchresults_i`;
  5. delimiter ;;
  6. CREATE DEFINER = `root`@`%` TRIGGER `sync$productmatchresults_i` AFTER INSERT ON `productmatchresults` FOR EACH ROW begin
  7. declare v_table_name varchar(64) default 'productmatchresults';
  8. declare v_method_type varchar(6) default 'insert';
  9. declare v_data_key text;
  10. declare v_data text;
  11. declare v_priority int default 1;
  12. set v_data_key=concat('{"pr_id": ', new.pr_id, '}');
  13. select concat(
  14. concat('{'),
  15. -- varchar
  16. concat('"pr_brandcn": ', case when new.pr_brandcn is null then 'null' else concat('"', replace(new.pr_brandcn, '"', '\\"'), '"') end),
  17. concat(',"pr_branden": ', case when new.pr_branden is null then 'null' else concat('"', replace(new.pr_branden, '"', '\\"'), '"') end),
  18. concat(',"pr_cmpcode": ', case when new.pr_cmpcode is null then 'null' else concat('"', replace(new.pr_cmpcode, '"', '\\"'), '"') end),
  19. concat(',"pr_uuid": ', case when new.pr_uuid is null then 'null' else concat('"', replace(new.pr_uuid, '"', '\\"'), '"') end),
  20. concat(',"pr_encapsulation": ', case when new.pr_encapsulation is null then 'null' else concat('"', replace(new.pr_encapsulation, '"', '\\"'), '"') end),
  21. concat(',"pr_kindcn": ', case when new.pr_kindcn is null then 'null' else concat('"', replace(new.pr_kindcn, '"', '\\"'), '"') end),
  22. concat(',"pr_kinden": ', case when new.pr_kinden is null then 'null' else concat('"', replace(new.pr_kinden, '"', '\\"'), '"') end),
  23. concat(',"pr_pbranduuid": ', case when new.pr_pbranduuid is null then 'null' else concat('"', replace(new.pr_pbranduuid, '"', '\\"'), '"') end),
  24. concat(',"pr_uuid": ', case when new.pr_uuid is null then 'null' else concat('"', replace(new.pr_uuid, '"', '\\"'), '"') end),
  25. -- bit(1), smallint(6), int(11), bigint(20), double
  26. concat(',"pr_brid": ', case when new.pr_brid is null then 'null' else new.pr_brid end),
  27. concat(',"pr_cmpid": ', case when new.pr_cmpid is null then 'null' else new.pr_cmpid end),
  28. concat(',"pr_enuu": ', case when new.pr_enuu is null then 'null' else new.pr_enuu end),
  29. concat(',"pr_kindid": ', case when new.pr_kindid is null then 'null' else new.pr_kindid end),
  30. concat(',"pr_number": ', case when new.pr_number is null then 'null' else new.pr_number end),
  31. concat(',"pr_prid": ', case when new.pr_prid is null then 'null' else new.pr_prid end),
  32. -- datetime
  33. -- text
  34. -- json
  35. concat('}')
  36. ) into v_data;
  37. call sync$enqueue_message(v_table_name, v_method_type, v_data_key, v_data, v_priority);
  38. end
  39. ;;
  40. delimiter ;
  41. -- ----------------------------
  42. -- Triggers structure for table productmatchresults
  43. -- ----------------------------
  44. DROP TRIGGER IF EXISTS `sync$productmatchresults_u`;
  45. delimiter ;;
  46. CREATE DEFINER = `root`@`%` TRIGGER `sync$productmatchresults_u` AFTER UPDATE ON `productmatchresults` FOR EACH ROW begin
  47. declare v_table_name varchar(64) default 'productmatchresults';
  48. declare v_method_type varchar(6) default 'update';
  49. declare v_data_key text;
  50. declare v_data text;
  51. declare v_priority int default 1;
  52. set v_data_key=concat('{"pr_id": ', old.pr_id, '}');
  53. select concat(
  54. concat('{'),
  55. -- varchar
  56. concat('"pr_brandcn": ', case when new.pr_brandcn is null then 'null' else concat('"', replace(new.pr_brandcn, '"', '\\"'), '"') end),
  57. concat(',"pr_branden": ', case when new.pr_branden is null then 'null' else concat('"', replace(new.pr_branden, '"', '\\"'), '"') end),
  58. concat(',"pr_cmpcode": ', case when new.pr_cmpcode is null then 'null' else concat('"', replace(new.pr_cmpcode, '"', '\\"'), '"') end),
  59. concat(',"pr_uuid": ', case when new.pr_uuid is null then 'null' else concat('"', replace(new.pr_uuid, '"', '\\"'), '"') end),
  60. concat(',"pr_encapsulation": ', case when new.pr_encapsulation is null then 'null' else concat('"', replace(new.pr_encapsulation, '"', '\\"'), '"') end),
  61. concat(',"pr_kindcn": ', case when new.pr_kindcn is null then 'null' else concat('"', replace(new.pr_kindcn, '"', '\\"'), '"') end),
  62. concat(',"pr_kinden": ', case when new.pr_kinden is null then 'null' else concat('"', replace(new.pr_kinden, '"', '\\"'), '"') end),
  63. concat(',"pr_pbranduuid": ', case when new.pr_pbranduuid is null then 'null' else concat('"', replace(new.pr_pbranduuid, '"', '\\"'), '"') end),
  64. concat(',"pr_uuid": ', case when new.pr_uuid is null then 'null' else concat('"', replace(new.pr_uuid, '"', '\\"'), '"') end),
  65. -- bit(1), smallint(6), int(11), bigint(20), double
  66. concat(',"pr_brid": ', case when new.pr_brid is null then 'null' else new.pr_brid end),
  67. concat(',"pr_cmpid": ', case when new.pr_cmpid is null then 'null' else new.pr_cmpid end),
  68. concat(',"pr_enuu": ', case when new.pr_enuu is null then 'null' else new.pr_enuu end),
  69. concat(',"pr_kindid": ', case when new.pr_kindid is null then 'null' else new.pr_kindid end),
  70. concat(',"pr_number": ', case when new.pr_number is null then 'null' else new.pr_number end),
  71. concat(',"pr_prid": ', case when new.pr_prid is null then 'null' else new.pr_prid end),
  72. -- datetime
  73. -- text
  74. -- json
  75. concat('}')
  76. ) into v_data;
  77. call sync$enqueue_message(v_table_name, v_method_type, v_data_key, v_data, v_priority);
  78. end
  79. ;;
  80. delimiter ;
  81. -- ----------------------------
  82. -- Triggers structure for table productmatchresults
  83. -- ----------------------------
  84. DROP TRIGGER IF EXISTS `sync$productmatchresults_d`;
  85. delimiter ;;
  86. CREATE DEFINER = `root`@`%` TRIGGER `sync$productmatchresults_d` AFTER DELETE ON `productmatchresults` FOR EACH ROW begin
  87. declare v_table_name varchar(64) default 'productmatchresults';
  88. declare v_method_type varchar(6) default 'delete';
  89. declare v_data_key text;
  90. declare v_data text;
  91. declare v_priority int default 1;
  92. set v_data_key=concat('{"pr_id": ', old.pr_id, '}');
  93. call sync$enqueue_message(v_table_name, v_method_type, v_data_key, v_data, v_priority);
  94. end
  95. ;;
  96. delimiter ;