02_install.sql 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. set define off
  2. set echo on
  3. whenever sqlerror exit sql.sqlcode
  4. alter session set container=ORCLPDB;
  5. alter session set current_schema=PMS_TEST;
  6. declare
  7. v_count number;
  8. v_xh number;
  9. v_fwc clob;
  10. v_obj json_object_t;
  11. v_arr json_array_t;
  12. v_out clob;
  13. v_found boolean;
  14. type t_gw is table of number;
  15. type t_names is table of varchar2(100);
  16. v_gws t_gw := t_gw(102121, 1015484);
  17. v_names t_names := t_names('fjyrjc', 'fjyrjc_ck', 'fjyrjc_lr');
  18. procedure add_service(p_name varchar2) is
  19. begin
  20. for i in 0 .. v_arr.get_size - 1 loop
  21. if v_arr.get_string(i) = p_name then
  22. v_found := true;
  23. exit;
  24. end if;
  25. end loop;
  26. end;
  27. begin
  28. select count(*)
  29. into v_count
  30. from PMS_TEST.GRCD
  31. where SJGRCDID = 1025885
  32. and DXM = 'fjyrjc';
  33. if v_count = 0 then
  34. select nvl(max(XH), -1) + 1
  35. into v_xh
  36. from PMS_TEST.GRCD
  37. where GRCDMBID = 1011
  38. and SJGRCDID = 1025885;
  39. insert into PMS_TEST.GRCD
  40. (SJGRCDID, GRCDMBID, CAIDLBM, XH, MC, YWM, DXM, GNM, JLZTM, MS)
  41. values
  42. (1025885, 1011, 1, v_xh, '风纪仪容检查', null,
  43. 'fjyrjc', 'search', 1, '风纪仪容检查');
  44. end if;
  45. for g in 1 .. v_gws.count loop
  46. select FWC
  47. into v_fwc
  48. from PMS_TEST.GW
  49. where GWID = v_gws(g)
  50. for update;
  51. v_obj := json_object_t.parse(v_fwc);
  52. v_arr := v_obj.get_array('bjpj');
  53. if v_arr is null then
  54. v_arr := json_array_t();
  55. end if;
  56. for n in 1 .. v_names.count loop
  57. v_found := false;
  58. add_service(v_names(n));
  59. if not v_found then
  60. v_arr.append(v_names(n));
  61. end if;
  62. end loop;
  63. v_obj.put('bjpj', v_arr);
  64. v_out := v_obj.stringify;
  65. update PMS_TEST.GW
  66. set FWC = v_out
  67. where GWID = v_gws(g);
  68. end loop;
  69. commit;
  70. dbms_output.put_line('FJYRJC_MENU_PERMISSION_OK');
  71. end;
  72. /
  73. exit