init-platformmanager.sql 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. -- 创建消息表
  2. drop table lucene$message;
  3. create table lucene$message(
  4. me_id number primary key,
  5. me_table_name varchar(64) not null,
  6. me_method_type varchar(6) not null,
  7. me_data_id number not null,
  8. me_data varchar(1024),
  9. me_priority number(2) default 0,
  10. me_retry_count number(1) default 0,
  11. me_create_time date not null
  12. );
  13. -- 创建消息历史表
  14. drop table lucene$message_history;
  15. create table lucene$message_history(
  16. mh_id number primary key,
  17. mh_dequeue_time date not null,
  18. me_id number not null,
  19. me_table_name varchar(64) not null,
  20. me_method_type varchar(6) not null,
  21. me_data_id number not null,
  22. me_data varchar(1024),
  23. me_priority number(2) default 0,
  24. me_create_time date not null
  25. );
  26. -- 创建序列
  27. drop sequence lucene_message_seq;
  28. create sequence lucene_message_seq
  29. start with 1
  30. increment by 1
  31. maxvalue 9999999999999999999999999999;
  32. drop sequence lucene_message_history_seq;
  33. create sequence lucene_message_history_seq
  34. start with 1
  35. increment by 1
  36. maxvalue 9999999999999999999999999999;
  37. -- 创建存储过程 入队消息
  38. create or replace procedure enqueue_lucene_message(v_table_name in varchar, v_method_type in varchar, v_data_id in number, v_data in varchar, v_priority in number) is
  39. begin
  40. insert into lucene$message (me_id, me_table_name, me_method_type, me_data_id, me_data, me_priority, me_create_time) values(lucene_message_seq.nextval, v_table_name, v_method_type, v_data_id, v_data, v_priority, sysdate());
  41. end enqueue_lucene_message;
  42. -- 创建存储过程 出队消息
  43. create or replace procedure dequeue_lucene_message(v_id in number) is
  44. begin
  45. insert into lucene$message_history (mh_id, mh_dequeue_time, me_id, me_table_name, me_method_type, me_data_id, me_data, me_priority, me_create_time) select lucene_message_history_seq.nextval, sysdate(), me_id, me_table_name, me_method_type, me_data_id, me_data, me_priority, me_create_time from lucene$message where me_id = v_id;
  46. delete from lucene$message where me_id = v_id;
  47. end dequeue_lucene_message;
  48. -- ----------------------------
  49. -- Triggers structure for table AC$US$DETAIL
  50. -- ----------------------------
  51. CREATE or replace trigger lucene_ac_us_detail
  52. after insert or update of name, shortname, id, industry, adminname, profession, tags or delete on AC$US$DETAIL
  53. for each row
  54. declare
  55. v_table_name varchar(64) default 'PURC$CHANGES';
  56. v_method_type varchar(6) default 'insert';
  57. v_data_id number;
  58. v_data varchar(1024) default null;
  59. v_priority number(2) default 1;
  60. begin
  61. if inserting then
  62. v_data_id := :new.id;
  63. elsif updating then
  64. v_data_id := :old.id;
  65. elsif deleting then
  66. v_data_id := :old.id;
  67. end if;
  68. enqueue_lucene_message(v_table_name, v_method_type, v_data_id, v_data, v_priority);
  69. end;