product$users.sql 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. -- ----------------------------
  2. -- Triggers structure for table product$users
  3. -- ----------------------------
  4. DROP TRIGGER IF EXISTS `sync$product_users_i`;
  5. delimiter ;;
  6. CREATE DEFINER = `root`@`%` TRIGGER `sync$product_users_i` AFTER INSERT ON `product$users` FOR EACH ROW begin
  7. declare v_table_name varchar(64) default 'product$users';
  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('{"PU_ID": ', new.PU_ID, '}');
  13. select concat(
  14. concat('{'),
  15. -- varchar
  16. -- bit(1), smallint(6), int(11), bigint(20), double
  17. concat('"PU_USERUU": ', case when new.PU_USERUU is null then 'null' else new.PU_USERUU end),
  18. concat(',"PU_ENUU": ', case when new.PU_ENUU is null then 'null' else new.PU_ENUU end),
  19. concat(',"PU_PRID": ', case when new.PU_PRID is null then 'null' else new.PU_PRID end),
  20. concat(',"PU_ERPID": ', case when new.PU_ERPID is null then 'null' else new.PU_ERPID end),
  21. -- datetime
  22. concat(',"PU_DATE": ', case when new.PU_DATE is null then 'null' else concat('"', replace(new.PU_DATE, '"', '\\"'), '"') end),
  23. -- text
  24. -- json
  25. concat('}')
  26. ) into v_data;
  27. call sync$enqueue_message(v_table_name, v_method_type, v_data_key, v_data, v_priority);
  28. end
  29. ;;
  30. delimiter ;
  31. -- ----------------------------
  32. -- Triggers structure for table product$users
  33. -- ----------------------------
  34. DROP TRIGGER IF EXISTS `sync$product_users_u`;
  35. delimiter ;;
  36. CREATE DEFINER = `root`@`%` TRIGGER `sync$product_users_u` AFTER UPDATE ON `product$users` FOR EACH ROW begin
  37. declare v_table_name varchar(64) default 'product$users';
  38. declare v_method_type varchar(6) default 'update';
  39. declare v_data_key text;
  40. declare v_data text;
  41. declare v_priority int default 1;
  42. set v_data_key=concat('{"PU_ID": ', old.PU_ID, '}');
  43. select concat(
  44. concat('{'),
  45. -- varchar
  46. -- bit(1), smallint(6), int(11), bigint(20), double
  47. concat('"PU_USERUU": ', case when new.PU_USERUU is null then 'null' else new.PU_USERUU end),
  48. concat(',"PU_ENUU": ', case when new.PU_ENUU is null then 'null' else new.PU_ENUU end),
  49. concat(',"PU_PRID": ', case when new.PU_PRID is null then 'null' else new.PU_PRID end),
  50. concat(',"PU_ERPID": ', case when new.PU_ERPID is null then 'null' else new.PU_ERPID end),
  51. -- datetime
  52. concat(',"PU_DATE": ', case when new.PU_DATE is null then 'null' else concat('"', replace(new.PU_DATE, '"', '\\"'), '"') end),
  53. -- text
  54. -- json
  55. concat('}')
  56. ) into v_data;
  57. call sync$enqueue_message(v_table_name, v_method_type, v_data_key, v_data, v_priority);
  58. end
  59. ;;
  60. delimiter ;
  61. -- ----------------------------
  62. -- Triggers structure for table product$users
  63. -- ----------------------------
  64. DROP TRIGGER IF EXISTS `sync$product_users_d`;
  65. delimiter ;;
  66. CREATE DEFINER = `root`@`%` TRIGGER `sync$product_users_d` AFTER DELETE ON `product$users` FOR EACH ROW begin
  67. declare v_table_name varchar(64) default 'product$users';
  68. declare v_method_type varchar(6) default 'delete';
  69. declare v_data_key text;
  70. declare v_data text;
  71. declare v_priority int default 1;
  72. set v_data_key=concat('{"PU_ID": ', old.PU_ID, '}');
  73. call sync$enqueue_message(v_table_name, v_method_type, v_data_key, v_data, v_priority);
  74. end
  75. ;;
  76. delimiter ;