为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:8
【操作系统】:
【CPU】:
【问题描述】*:
下面是达梦的
CREATE VIEW “SYSDBA”.“std_biz_term_aprv_view” (“std_clss_id”,“std_item_grp_id_arr”,“std_item_grp_id_path_arr”,“std_item_id”,“aprv_aplct_id”,“aplct_typ”,“aplct_typ_nm”,“usr_id”,“usr_nm”,“aprv_aplct_tm”,“aprv_aplct_tm_format”,“std_item_chn_nm”,“std_item_eng_nm”,“std_item_eng_abbr”,“std_item_desc”,“std_item_typ”,“cd_val_hv_flg”,“logcl_dttyp_id”,“logcl_dttyp_nm”,“aprv_stat”,“aprv_rslt”,“aprv_sugst”,“biz_term_flg”,“aplct_src”,“dt_len”,“prcsn”,“mesr_unit”,“biz_mean”,“senty”,“rltd_std”,“std_bus_rul”,“range_value”,“biz_dttyp_id”,“biz_dttyp_nm”,“std_bh”,“std_alas”,“auth_doc_nm”,“aprv_org_id_arr”,“aprv_org_nm_arr”,“involver_org_id_arr”,“involver_org_nm_arr”,“rel_std_item_id”,“rel_std_item_chn_nm”)
AS
with recursive “t_grp” as (select “grp”.“std_item_grp_id” AS “std_item_grp_id”,“grp”.“std_item_grp_nm” AS “std_item_grp_nm”,“grp”.“upp_std_item_grp_id” AS “upp_std_item_grp_id”,“grp”.“std_item_grp_ord_num” AS “std_item_grp_ord_num”,cast(“grp”.“std_item_grp_id” as char(4000) charset utf8mb4) AS “std_item_grp_id_path” from “std_item_grp” “grp” where ((“grp”.“upp_std_item_grp_id” = ‘root’) and (“grp”.“std_item_grp_typ” = ‘tg’) and (“grp”.“disabld_tm” = ‘99999999999999’)) union all select “grp1”.“std_item_grp_id” AS “std_item_grp_id”,“grp1”.“std_item_grp_nm” AS “std_item_grp_nm”,“grp1”.“upp_std_item_grp_id” AS “upp_std_item_grp_id”,“grp1”.“std_item_grp_ord_num” AS “std_item_grp_ord_num”,concat_ws(‘/’,“grp2”.“std_item_grp_id_path”,cast(“grp1”.“std_item_grp_id” as char(4000) charset utf8mb4)) AS “std_item_grp_id_path” from (“std_item_grp” “grp1” join “t_grp” “grp2” on(((“grp2”.“std_item_grp_id” = “grp1”.“upp_std_item_grp_id”) and (“grp1”.“disabld_tm” = ‘99999999999999’))))), “t_grp_rel” as (select “grp_rel”.“aprv_aplct_id” AS “aprv_aplct_id”,“grp_rel”.“std_item_id” AS “std_item_id”,group_concat(“grp_rel”.“std_item_grp_id” order by “grp_rel”.“std_item_grp_id” ASC separator ‘,’) AS “std_item_grp_id_arr”,group_concat(“t_grp”.“std_item_grp_id_path” order by “t_grp”.“std_item_grp_id” ASC separator ‘,’) AS “std_item_grp_id_path_arr” from (“std_item_grp_item_rel_aprv” “grp_rel” left join “t_grp” on((“grp_rel”.“std_item_grp_id” = “t_grp”.“std_item_grp_id”))) group by “grp_rel”.“aprv_aplct_id”,“grp_rel”.“std_item_id”), “t_auth_doc” as (select “doc_rel”.“aprv_aplct_id” AS “aprv_aplct_id”,“doc_rel”.“std_item_id” AS “std_item_id”,group_concat(if((“auth_doc”.“auth_doc_no” is null),concat(‘《’,“auth_doc”.“auth_doc_nm”,‘》’),concat(‘《’,“auth_doc”.“auth_doc_no”,’ ‘,“auth_doc”.“auth_doc_nm”,’》‘)) order by “auth_doc”.“auth_doc_nm” ASC separator ‘,’) AS “auth_doc_nm” from (“std_item_doc_rel_aprv” “doc_rel” left join “auth_doc” on(((“doc_rel”.“auth_doc_id” = “auth_doc”.“auth_doc_id”) and (“auth_doc”.“enabld_yn” = ‘y’)))) group by “doc_rel”.“aprv_aplct_id”,“doc_rel”.“std_item_id”), “t_aprv_org” as (select “org_rel”.“aprv_aplct_id” AS “aprv_aplct_id”,“org_rel”.“std_item_id” AS “std_item_id”,group_concat(“org_rel”.“org_id” order by “org_rel”.“std_rltd_org_ord_num” ASC separator ‘,’) AS “aprv_org_id_arr”,group_concat(“org”.“usr_nm” order by “org_rel”.“std_rltd_org_ord_num” ASC separator ‘,’) AS “aprv_org_nm_arr” from (“std_rltd_org_aprv” “org_rel” left join “t_usr_ba” “org” on((“org_rel”.“org_id” = “org”.“usr_id”))) where (“org_rel”.“std_rltd_org_typ” = ‘0001’) group by “org_rel”.“aprv_aplct_id”,“org_rel”.“std_item_id”), “t_involver_org” as (select “org_rel”.“aprv_aplct_id” AS “aprv_aplct_id”,“org_rel”.“std_item_id” AS “std_item_id”,group_concat(“org_rel”.“org_id” order by “org_rel”.“std_rltd_org_ord_num” ASC separator ‘,’) AS “involver_org_id_arr”,group_concat(“org”.“usr_nm” order by “org_rel”.“std_rltd_org_ord_num” ASC separator ‘,’) AS “involver_org_nm_arr” from (“std_rltd_org_aprv” “org_rel” left join “t_usr_ba” “org” on((“org_rel”.“org_id” = “org”.“usr_id”))) where (“org_rel”.“std_rltd_org_typ” = ‘0003’) group by “org_rel”.“aprv_aplct_id”,“org_rel”.“std_item_id”) select “a”.“std_clss_id” AS “std_clss_id”,“a”.“std_item_grp_id_arr” AS “std_item_grp_id_arr”,“a”.“std_item_grp_id_path_arr” AS “std_item_grp_id_path_arr”,“a”.“std_item_id” AS “std_item_id”,“a”.“aprv_aplct_id” AS “aprv_aplct_id”,“a”.“aplct_typ” AS “aplct_typ”,(case when (“a”.“aplct_typ” = ‘a’) then ‘新增’ when (“a”.“aplct_typ” = ‘m’) then ‘修改’ when (“a”.“aplct_typ” = ‘d’) then ‘废止’ when (“a”.“aplct_typ” = ‘r’) then ‘还原’ end) AS “aplct_typ_nm”,“a”.“usr_id” AS “usr_id”,“a”.“usr_nm” AS “usr_nm”,“a”.“aprv_aplct_tm” AS “aprv_aplct_tm”,date_format(str_to_date(“a”.“aprv_aplct_tm”,’%y%m%d %h%i%s’),‘%y-%m-%d %h:%i:%s’) AS “aprv_aplct_tm_format”,“a”.“std_item_chn_nm” AS “std_item_chn_nm”,“a”.“std_item_eng_nm” AS “std_item_eng_nm”,“a”.“std_item_eng_abbr” AS “std_item_eng_abbr”,“a”.“std_item_desc” AS “std_item_desc”,“a”.“std_item_typ” AS “std_item_typ”,“a”.“cd_val_hv_flg” AS “cd_val_hv_flg”,“a”.“logcl_dttyp_id” AS “logcl_dttyp_id”,“a”.“logcl_dttyp_nm” AS “logcl_dttyp_nm”,“a”.“aprv_stat” AS “aprv_stat”,“a”.“aprv_rslt” AS “aprv_rslt”,“a”.“aprv_sugst” AS “aprv_sugst”,“a”.“biz_term_flg” AS “biz_term_flg”,“a”.“aplct_src” AS “aplct_src”,“a”.“dt_len” AS “dt_len”,“a”.“prcsn” AS “prcsn”,“a”.“mesr_unit” AS “mesr_unit”,“a”.“biz_mean” AS “biz_mean”,“a”.“senty” AS “senty”,“a”.“rltd_std” AS “rltd_std”,“a”.“std_bus_rul” AS “std_bus_rul”,“a”.“range_value” AS “range_value”,“a”.“biz_dttyp_id” AS “biz_dttyp_id”,“a”.“biz_dttyp_nm” AS “biz_dttyp_nm”,“a”.“std_bh” AS “std_bh”,“a”.“std_alas” AS “std_alas”,“a”.“auth_doc_nm” AS “auth_doc_nm”,“a”.“aprv_org_id_arr” AS “aprv_org_id_arr”,“a”.“aprv_org_nm_arr” AS “aprv_org_nm_arr”,“a”.“involver_org_id_arr” AS “involver_org_id_arr”,“a”.“involver_org_nm_arr” AS “involver_org_nm_arr”,“a”.“rel_std_item_id” AS “rel_std_item_id”,“a”.“rel_std_item_chn_nm” AS “rel_std_item_chn_nm” from (select “a”.“std_clss_id” AS “std_clss_id”,“c”.“std_item_grp_id_arr” AS “std_item_grp_id_arr”,“c”.“std_item_grp_id_path_arr” AS “std_item_grp_id_path_arr”,“a”.“std_item_id” AS “std_item_id”,“a”.“aprv_aplct_id” AS “aprv_aplct_id”,“a”.“aplct_typ” AS “aplct_typ”,“a”.“usr_id” AS “usr_id”,“i”.“usr_nm” AS “usr_nm”,“j”.“aprv_aplct_tm” AS “aprv_aplct_tm”,“a”.“std_item_chn_nm” AS “std_item_chn_nm”,“a”.“std_item_eng_nm” AS “std_item_eng_nm”,“a”.“std_item_eng_abbr” AS “std_item_eng_abbr”,“a”.“std_item_desc” AS “std_item_desc”,“a”.“std_item_typ” AS “std_item_typ”,“a”.“cd_val_hv_flg” AS “cd_val_hv_flg”,“a”.“logcl_dttyp_id” AS “logcl_dttyp_id”,“b”.“logcl_dttyp_nm” AS “logcl_dttyp_nm”,“a”.“aprv_stat” AS “aprv_stat”,“a”.“aprv_rslt” AS “aprv_rslt”,“a”.“aprv_sugst” AS “aprv_sugst”,“a”.“biz_term_flg” AS “biz_term_flg”,“a”.“aplct_src” AS “aplct_src”,“a”.“dt_len” AS “dt_len”,“a”.“prcsn” AS “prcsn”,“a”.“mesr_unit” AS “mesr_unit”,“a”.“biz_mean” AS “biz_mean”,“a”.“ext_01_txt” AS “senty”,“a”.“ext_02_txt” AS “rltd_std”,“a”.“ext_05_txt” AS “std_bus_rul”,“a”.“ext_08_txt” AS “range_value”,“a”.“ext_10_txt” AS “biz_dttyp_id”,“h”.“std_item_grp_nm” AS “biz_dttyp_nm”,“a”.“ext_11_txt” AS “std_bh”,“a”.“ext_12_txt” AS “std_alas”,“d”.“auth_doc_nm” AS “auth_doc_nm”,“e”.“aprv_org_id_arr” AS “aprv_org_id_arr”,“e”.“aprv_org_nm_arr” AS “aprv_org_nm_arr”,“f”.“involver_org_id_arr” AS “involver_org_id_arr”,“f”.“involver_org_nm_arr” AS “involver_org_nm_arr”,“k”.“upp_std_item_id” AS “rel_std_item_id”,“g”.“std_item_chn_nm” AS “rel_std_item_chn_nm” from ((((((((((“std_item_aprv” “a” left join “logcl_dttyp” “b” on((“a”.“logcl_dttyp_id” = “b”.“logcl_dttyp_id”))) left join “t_grp_rel” “c” on(((“a”.“std_item_id” = “c”.“std_item_id”) and (“a”.“aprv_aplct_id” = “c”.“aprv_aplct_id”)))) left join “t_auth_doc” “d” on(((“a”.“std_item_id” = “d”.“std_item_id”) and (“a”.“aprv_aplct_id” = “d”.“aprv_aplct_id”)))) left join “t_aprv_org” “e” on(((“a”.“std_item_id” = “e”.“std_item_id”) and (“a”.“aprv_aplct_id” = “e”.“aprv_aplct_id”)))) left join “t_involver_org” “f” on(((“a”.“std_item_id” = “f”.“std_item_id”) and (“a”.“aprv_aplct_id” = “f”.“aprv_aplct_id”)))) left join “std_item_grp” “h” on(((“a”.“ext_10_txt” = “h”.“std_item_grp_id”) and (“h”.“disabld_tm” = ‘99999999999999’)))) left join “std_item_rel_aprv” “k” on(((“k”.“low_std_item_id” = “a”.“std_item_id”) and (“k”.“aprv_aplct_id” = “a”.“aprv_aplct_id”) and (“k”.“std_item_rel_typ” = ‘3004’)))) left join “std_item” “g” on(((“g”.“std_item_id” = “k”.“upp_std_item_id”) and (“g”.“disabld_tm” = ‘99999999999999’) and (“g”.“std_item_typ” = ‘t’)))) left join “t_usr_ba” “i” on((“a”.“usr_id” = “i”.“usr_id”))) left join “aprv_aplct” “j” on((“a”.“aprv_aplct_id” = “j”.“aprv_aplct_id”))) where ((“a”.“std_item_typ” = ‘t’) and (“a”.“aplct_src” = ‘biz’))) “a” order by “a”.“aprv_aplct_tm” desc; 好像是with recursive这里的问题
您试试执行附件这个语句,然后看看视图的效果。
视图修改.sql