T100——q查询,子母查询(汇总——明细)练习笔记
范例:
代码:
#add-point:input段落 name="ui_dialog.input"
INPUT BY NAME g_master.bdate,g_master.edate,g_master.l_group
ATTRIBUTE(WITHOUT DEFAULTS) AFTER FIELD edate
IF NOT cl_null(g_master.edate) AND NOT cl_null(g_master.bdate) THEN
IF g_master.edate < g_master.bdate THEN
LET g_master.edate = NULL
DISPLAY g_master.edate TO edate
NEXT FIELD edate
END IF
END IF END INPUT
#end add-point
#add-point:construct段落 name="ui_dialog.construct"
CONSTRUCT BY NAME g_master.wc ON pmdo001,imaa009,pmaa080,pmdl004 ON ACTION controlp INFIELD pmdo001
INITIALIZE g_qryparam.* TO NULL
LET g_qryparam.state = 'c'
LET g_qryparam.reqry = FALSE
CALL q_imaf001() #呼叫開窗
DISPLAY g_qryparam.return1 TO pmdo001 #顯示到畫面上
NEXT FIELD pmdo001 #返回原欄位 ON ACTION controlp INFIELD imaa009
INITIALIZE g_qryparam.* TO NULL
LET g_qryparam.state = 'c'
LET g_qryparam.reqry = FALSE
CALL q_rtax001() #呼叫開窗
DISPLAY g_qryparam.return1 TO imaa009 #顯示到畫面上
NEXT FIELD imaa009 #返回原欄位 ON ACTION controlp INFIELD pmaa080
INITIALIZE g_qryparam.* TO NULL
LET g_qryparam.state = 'c'
LET g_qryparam.reqry = FALSE
LET g_qryparam.arg1 = '251'
CALL q_oocq002() #呼叫開窗
DISPLAY g_qryparam.return1 TO pmaa080 #顯示到畫面上
NEXT FIELD pmaa080 #返回原欄位 ON ACTION controlp INFIELD pmdl004
INITIALIZE g_qryparam.* TO NULL
LET g_qryparam.state = 'c'
LET g_qryparam.reqry = FALSE
CALL q_pmaa001_3() #呼叫開窗
DISPLAY g_qryparam.return1 TO pmdl004 #顯示到畫面上
NEXT FIELD pmdl004 #返回原欄位 END CONSTRUCT
#end add-point
双击汇总,打开对应报表;
#add-point:page1自定義行為 name="ui_dialog.body.page1.action"
ON ACTION modify_detail
LET l_wc_web = l_wc
LET l_wc_web = cl_replace_str(l_wc_web,"pmdo001","imaa001")
LET l_wc_web = cl_replace_str(l_wc_web,"pmdl004","pmaa001")
CASE g_master.l_group
WHEN '1'
CALL apmr006_x01(l_wc_web)
WHEN '2'
CALL apmr006_x02(l_wc_web)
WHEN '3'
CALL apmr006_x03(l_wc_web)
WHEN '4'
CALL apmr006_x04(l_wc_web)
WHEN '5'
CALL apmr006_x05(l_wc_web)
END CASE
#end add-point
#+ 單身陣列填充
PRIVATE FUNCTION cpmq006_b_fill()
#add-point:b_fill段define-客製 name="b_fill.define_customerization" #end add-point
DEFINE ls_wc STRING
DEFINE l_pid LIKE type_t.chr50
DEFINE ls_sql_rank STRING
#add-point:b_fill段define-標準 (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="b_fill.define" #end add-point #add-point:b_fill段sql_before name="b_fill.sql_before"
CALL cl_set_comp_visible("b_pmdl004,b_pmdl004_desc,b_pmdl002,b_pmdl002_desc,b_pmdl003,b_pmdl003_desc,b_pmdo001,b_pmdo001_desc,b_pmdo001_desc_1,b_imaa009,b_imaa009_desc",FALSE)
CASE g_master.l_group
WHEN '1' #供应商编码
CALL cl_set_comp_visible("b_pmdl004,b_pmdl004_desc",TRUE)
WHEN '2' #采购人员
CALL cl_set_comp_visible("b_pmdl002,b_pmdl002_desc",TRUE)
WHEN '3' #采购部门
CALL cl_set_comp_visible("b_pmdl003,b_pmdl003_desc",TRUE)
WHEN '4' #产品分类
CALL cl_set_comp_visible("b_imaa009,b_imaa009_desc",TRUE)
WHEN '5' #料件编号
CALL cl_set_comp_visible("b_pmdo001,b_pmdo001_desc,b_pmdo001_desc_1",TRUE)
END CASE IF cl_null(g_master.wc) THEN
LET g_master.wc = " pmdlsite = '",g_site CLIPPED,"' AND pmdlent = '",g_enterprise CLIPPED,"' "
ELSE
LET g_master.wc = g_master.wc CLIPPED," AND pmdlsite = '",g_site CLIPPED,"' AND pmdlent = '",g_enterprise CLIPPED,"' "
END IF LET g_master.wc = g_master.wc CLIPPED," AND (pmdl005 = '1' OR pmdl005 = '2' OR pmdl005 = '3' OR pmdl005 = '5' ) AND pmdlstus='Y'" IF NOT cl_null(g_master.bdate) THEN
LET g_master.wc = g_master.wc , " AND pmdldocdt >= to_date( '",g_master.bdate,"','yy/mm/dd') "
END IF IF NOT cl_null(g_master.edate) THEN
LET g_master.wc = g_master.wc , " AND pmdldocdt <= to_date('",g_master.edate,"','yy/mm/dd') "
END IF LET l_wc = g_master.wc
#end add-point IF cl_null(g_wc_filter) THEN
LET g_wc_filter = " 1=1"
END IF
IF cl_null(g_wc) THEN
LET g_wc = " 1=1"
END IF
IF cl_null(g_wc2) THEN
LET g_wc2 = " 1=1"
END IF LET ls_wc = g_wc, " AND ", g_wc2, " AND ", g_wc_filter CALL g_pmdl_d.clear() #add-point:陣列清空 name="b_fill.array_clear" #end add-point LET g_cnt = l_ac
IF g_cnt = 0 THEN
LET g_cnt = 1
END IF
LET l_ac = 1 # b_fill段sql組成及FOREACH撰寫
#應用 qs04 樣板自動產生(Version:9)
#+ b_fill段資料取得(包含sql組成及FOREACH段撰寫)
LET ls_sql_rank = "SELECT UNIQUE pmdl004,'',pmdl002,'',pmdl003,'','','','','','','','','','' ,DENSE_RANK() OVER( ORDER BY pmdl_t.pmdldocno) AS RANK FROM pmdl_t", #table2
" LEFT JOIN pmdn_t ON pmdnent = pmdlent AND pmdldocno = pmdndocno", "",
" WHERE pmdlent= ? AND 1=1 AND ", ls_wc
LET ls_sql_rank = ls_sql_rank, cl_sql_add_filter("pmdl_t"),
" ORDER BY pmdl_t.pmdldocno" #add-point:b_fill段rank_sql_after name="b_fill.rank_sql_after"
LET ls_sql_rank = " SELECT pmdl004,pmaal003,pmdl002,ooag011,pmdl003,ooefl003,pmdo001,imaal003,imaal004,imaa009,rtaxl003,pmdo006,pmdo033 ",
" FROM pmdo_t ",
" LEFT JOIN pmdn_t ON pmdnent=pmdoent AND pmdndocno=pmdodocno AND pmdnseq=pmdoseq ",
" LEFT JOIN pmdl_t ON pmdlent=pmdnent AND pmdldocno=pmdndocno ",
" LEFT JOIN imaa_t ON imaaent=pmdnent AND imaa001=pmdn001 ",
" LEFT JOIN pmaa_t ON pmaaent=pmdlent AND pmaa001=pmdl004 ",
" LEFT JOIN pmaal_t ON pmaalent=pmdlent AND pmaal001=pmdl004 AND pmaal002='zh_CN' ",
" LEFT JOIN ooag_t ON ooagent=pmdlent AND ooag001=pmdl002 ",
" LEFT JOIN ooefl_t ON ooeflent=pmdlent AND ooefl001=pmdl003 AND ooefl002='zh_CN' ",
" LEFT JOIN imaal_t ON imaaent=pmdnent AND imaal001=pmdn001 AND imaal002='zh_CN' ",
" LEFT JOIN rtaxl_t ON rtaxlent=imaaent AND rtaxl001=imaa009 AND rtaxl002='zh_CN' ",
" WHERE ",l_wc CLIPPED
{
#end add-point LET g_sql = "SELECT COUNT(1) FROM (",ls_sql_rank,")" PREPARE b_fill_cnt_pre FROM g_sql #總筆數
EXECUTE b_fill_cnt_pre USING g_enterprise INTO g_tot_cnt
FREE b_fill_cnt_pre #add-point:b_fill段rank_sql_after_count name="b_fill.rank_sql_after_count"
}
LET g_sql = "SELECT COUNT(1) FROM (",ls_sql_rank,")" PREPARE b_fill_cnt_pre FROM g_sql #總筆數
EXECUTE b_fill_cnt_pre INTO g_tot_cnt
FREE b_fill_cnt_pre
#end add-point CASE g_detail_page_action
WHEN "detail_first"
LET g_pagestart = 1 WHEN "detail_previous"
LET g_pagestart = g_pagestart - g_num_in_page
IF g_pagestart < 1 THEN
LET g_pagestart = 1
END IF WHEN "detail_next"
LET g_pagestart = g_pagestart + g_num_in_page
IF g_pagestart > g_tot_cnt THEN
LET g_pagestart = g_tot_cnt - (g_tot_cnt mod g_num_in_page) + 1
WHILE g_pagestart > g_tot_cnt
LET g_pagestart = g_pagestart - g_num_in_page
END WHILE
END IF WHEN "detail_last"
LET g_pagestart = g_tot_cnt - (g_tot_cnt mod g_num_in_page) + 1
WHILE g_pagestart > g_tot_cnt
LET g_pagestart = g_pagestart - g_num_in_page
END WHILE OTHERWISE
LET g_pagestart = 1 END CASE LET g_sql = "SELECT pmdl004,'',pmdl002,'',pmdl003,'','','','','','','','','',''",
" FROM (",ls_sql_rank,")",
" WHERE RANK >= ",g_pagestart,
" AND RANK < ",g_pagestart + g_num_in_page #add-point:b_fill段sql_after name="b_fill.sql_after"
LET g_sql = " WITH t1 AS ( ",
" SELECT pmdl004,pmaal003,pmdl002,ooag011,pmdl003,ooefl003,pmdo001,imaal003,imaal004,imaa009,rtaxl003,pmdo006,pmdo033 ",
" FROM pmdo_t ",
" LEFT JOIN pmdn_t ON pmdnent=pmdoent AND pmdndocno=pmdodocno AND pmdnseq=pmdoseq ",
" LEFT JOIN pmdl_t ON pmdlent=pmdnent AND pmdldocno=pmdndocno ",
" LEFT JOIN imaa_t ON imaaent=pmdnent AND imaa001=pmdn001 ",
" LEFT JOIN pmaa_t ON pmaaent=pmdlent AND pmaa001=pmdl004 ",
" LEFT JOIN pmaal_t ON pmaalent=pmdlent AND pmaal001=pmdl004 AND pmaal002='zh_CN' ",
" LEFT JOIN ooag_t ON ooagent=pmdlent AND ooag001=pmdl002 ",
" LEFT JOIN ooefl_t ON ooeflent=pmdlent AND ooefl001=pmdl003 AND ooefl002='zh_CN' ",
" LEFT JOIN imaal_t ON imaaent=pmdnent AND imaal001=pmdn001 AND imaal002='zh_CN' ",
" LEFT JOIN rtaxl_t ON rtaxlent=imaaent AND rtaxl001=imaa009 AND rtaxl002='zh_CN' ",
" WHERE pmdoent=? AND ",l_wc CLIPPED," ) " CASE g_master.l_group
WHEN '1' #供应商编码
LET g_sql = g_sql, " SELECT pmdl004,pmaal003,'','','','','','','','','',SUM(pmdo006),to_char(SUM(pmdo006)/(SELECT SUM(pmdo006) FROM t1)*100,'fm990.99')||'%',SUM(pmdo033),to_char(SUM(pmdo033)/(SELECT SUM(pmdo033) FROM t1)*100,'fm990.99')||'%' ",
" FROM t1 ",
" GROUP BY pmdl004,pmaal003 ",
" ORDER BY pmdl004 "
WHEN '2' #采购人员
LET g_sql = g_sql, " SELECT '','',pmdl002,ooag011,'','','','','','','',SUM(pmdo006),to_char(SUM(pmdo006)/(SELECT SUM(pmdo006) FROM t1)*100,'fm990.99')||'%',SUM(pmdo033),to_char(SUM(pmdo033)/(SELECT SUM(pmdo033) FROM t1)*100,'fm990.99')||'%' ",
" FROM t1 ",
" GROUP BY pmdl002,ooag011 ",
" ORDER BY pmdl002 "
WHEN '3' #采购部门
LET g_sql = g_sql, " SELECT '','','','',pmdl003,ooefl003,'','','','','',SUM(pmdo006),to_char(SUM(pmdo006)/(SELECT SUM(pmdo006) FROM t1)*100,'fm990.99')||'%',SUM(pmdo033),to_char(SUM(pmdo033)/(SELECT SUM(pmdo033) FROM t1)*100,'fm990.99')||'%' ",
" FROM t1 ",
" GROUP BY pmdl003,ooefl003 ",
" ORDER BY pmdl003 "
WHEN '4' #产品分类
LET g_sql = g_sql, " SELECT '','','','','','','','','',imaa009,rtaxl003,SUM(pmdo006),to_char(SUM(pmdo006)/(SELECT SUM(pmdo006) FROM t1)*100,'fm990.99')||'%',SUM(pmdo033),to_char(SUM(pmdo033)/(SELECT SUM(pmdo033) FROM t1)*100,'fm990.99')||'%' ",
" FROM t1 ",
" GROUP BY imaa009,rtaxl003 ",
" ORDER BY imaa009 "
WHEN '5' #料件编号
LET g_sql = g_sql, " SELECT '','','','','','',pmdo001,imaal003,imaal004,'','',SUM(pmdo006),to_char(SUM(pmdo006)/(SELECT SUM(pmdo006) FROM t1)*100,'fm990.99')||'%',SUM(pmdo033),to_char(SUM(pmdo033)/(SELECT SUM(pmdo033) FROM t1)*100,'fm990.99')||'%' ",
" FROM t1 ",
" GROUP BY pmdo001,imaal003,imaal004 ",
" ORDER BY pmdo001 "
END CASE
#end add-point LET g_sql = cl_sql_add_mask(g_sql) #遮蔽特定資料
PREPARE cpmq006_pb FROM g_sql
DECLARE b_fill_curs CURSOR FOR cpmq006_pb OPEN b_fill_curs USING g_enterprise FOREACH b_fill_curs INTO g_pmdl_d[l_ac].pmdl004,g_pmdl_d[l_ac].pmdl004_desc,g_pmdl_d[l_ac].pmdl002,
g_pmdl_d[l_ac].pmdl002_desc,g_pmdl_d[l_ac].pmdl003,g_pmdl_d[l_ac].pmdl003_desc,g_pmdl_d[l_ac].pmdo001,
g_pmdl_d[l_ac].pmdo001_desc,g_pmdl_d[l_ac].pmdo001_desc_1,g_pmdl_d[l_ac].imaa009,g_pmdl_d[l_ac].imaa009_desc,
g_pmdl_d[l_ac].l_sum_cnt,g_pmdl_d[l_ac].l_sum_cntb,g_pmdl_d[l_ac].l_sum_money,g_pmdl_d[l_ac].l_sum_moneyb IF SQLCA.sqlcode THEN
INITIALIZE g_errparam TO NULL
LET g_errparam.extend = "FOREACH:"
LET g_errparam.code = SQLCA.sqlcode
LET g_errparam.popup = TRUE
CALL cl_err() EXIT FOREACH
END IF #add-point:b_fill段資料填充 name="b_fill.fill" #end add-point CALL cpmq006_detail_show("'1'") CALL cpmq006_pmdl_t_mask() IF l_ac > g_max_rec THEN
IF g_error_show = 1 THEN
INITIALIZE g_errparam TO NULL
LET g_errparam.extend = ""
LET g_errparam.code = 9035
LET g_errparam.popup = TRUE
CALL cl_err() END IF
EXIT FOREACH
END IF
LET l_ac = l_ac + 1 END FOREACH #應用 qs05 樣板自動產生(Version:3)
#+ b_fill段其他table資料取得(包含sql組成及資料填充) #add-point:b_fill段資料填充(其他單身) name="b_fill.others.fill" #end add-point CALL g_pmdl_d.deleteElement(g_pmdl_d.getLength()) #add-point:陣列長度調整 name="b_fill.array_deleteElement" #end add-point LET g_error_show = 0 LET g_detail_cnt = g_pmdl_d.getLength()
LET l_ac = g_cnt
LET g_cnt = 0 #應用 qs06 樣板自動產生(Version:3)
#+ b_fill段CURSOR釋放
CLOSE b_fill_curs
FREE cpmq006_pb #調整單身index指標,避免翻頁後指到空白筆數
CALL cpmq006_detail_index_setting() #重新計算單身筆數並呈現
CALL cpmq006_detail_action_trans() LET l_ac = 1
IF g_pmdl_d.getLength() > 0 THEN
CALL cpmq006_b_fill2()
END IF CALL cpmq006_filter_show('pmdl004','b_pmdl004')
CALL cpmq006_filter_show('pmdl002','b_pmdl002')
CALL cpmq006_filter_show('pmdl003','b_pmdl003')
CALL cpmq006_filter_show('pmdo001','b_pmdo001')
CALL cpmq006_filter_show('imaa009','b_imaa009')
CALL cpmq006_filter_show('pmdlstus','b_pmdlstus') END FUNCTION
#+ 單身陣列填充2
PRIVATE FUNCTION cpmq006_b_fill2()
#add-point:b_fill2段define-客製 name="b_fill2.define_customerization" #end add-point
DEFINE li_ac LIKE type_t.num10
#add-point:b_fill2段define-標準 (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="b_fill2.define" #end add-point #add-point:FUNCTION前置處理 name="b_fill2.before_function" #end add-point LET li_ac = l_ac #單身組成
#應用 qs07 樣板自動產生(Version:6)
#+ b_fill2段table資料取得(包含sql組成及資料填充)
#Page2
CALL g_pmdl2_d.clear() #add-point:陣列清空 name="b_fill2.array_clear"
{
#end add-point #table2
#為避免影響執行效能,若是按上下筆就不重組SQL
IF g_action_choice <> "fetch" OR cl_null(g_action_choice) THEN
LET g_sql = "SELECT UNIQUE '','','','','','','','','','','','','','','','','','','','','','',
'','','','','','','','','','',pmdnud001,pmdn015,pmdn045,pmdn049,'',pmdn051,'' FROM pmdn_t", "",
" WHERE pmdnent=? AND pmdndocno=?" IF NOT cl_null(g_wc2_table2) THEN
LET g_sql = g_sql CLIPPED," AND ",g_wc2_table2 CLIPPED
END IF LET g_sql = g_sql, " ORDER BY pmdn_t.pmdnseq" #add-point:單身填充前 name="b_fill2.before_fill2"
}
LET g_sql = " SELECT pmdldocno,pmdldocdt,pmdl004,pmaal003,pmdl002,ooag011,pmdl003,ooefl003,pmdl005,pmdlud002,pmdlstus,pmdoseq, ",
" pmdoseq1,pmdoseq2,pmdo003,pmdo001,imaal003,imaal004,pmdo004,pmdo005,pmdo006,pmdo011,pmdo012,pmdo013,pmdo009, ",
" pmdo015,pmdo016,pmdo017,pmdo040,pmdo019,pmdo024,pmdo033,pmdnud001,pmdn015,pmdn045,pmdn049,oq1.oocql004,pmdn051,oq2.oocql004 ",
" FROM pmdo_t ",
" LEFT JOIN pmdn_t ON pmdnent=pmdoent AND pmdndocno=pmdodocno AND pmdnseq=pmdoseq ",
" LEFT JOIN pmdl_t ON pmdlent=pmdnent AND pmdldocno=pmdndocno ",
" LEFT JOIN imaa_t ON imaaent=pmdnent AND imaa001=pmdn001 ",
" LEFT JOIN pmaa_t ON pmaaent=pmdlent AND pmaa001=pmdl004 ",
" LEFT JOIN pmaal_t ON pmaalent=pmdlent AND pmaal001=pmdl004 AND pmaal002='zh_CN' ",
" LEFT JOIN ooag_t ON ooagent=pmdlent AND ooag001=pmdl002 ",
" LEFT JOIN ooefl_t ON ooeflent=pmdlent AND ooefl001=pmdl003 AND ooefl002='zh_CN' ",
" LEFT JOIN imaal_t ON imaaent=pmdnent AND imaal001=pmdn001 AND imaal002='zh_CN' ",
" LEFT JOIN rtaxl_t ON rtaxlent=imaaent AND rtaxl001=imaa009 AND rtaxl002='zh_CN' ",
" LEFT JOIN oocql_t oq1 ON oq1.oocqlent=pmdnent AND oq1.oocql001='265' AND oq1.oocql002=pmdn049 AND oq1.oocql003='zh_CN' ",
" LEFT JOIN oocql_t oq2 ON oq2.oocqlent=pmdnent AND oq2.oocql001 IN ('258','317') AND oq2.oocql002=pmdn051 AND oq2.oocql003='zh_CN' ",
" WHERE ",l_wc CLIPPED CASE g_master.l_group
WHEN '1' #供应商编码
LET g_sql = g_sql, " AND pmdl004 = '",g_pmdl_d[g_detail_idx].pmdl004,"' "
WHEN '2' #采购人员
LET g_sql = g_sql, " AND pmdl002 = '",g_pmdl_d[g_detail_idx].pmdl002,"' "
WHEN '3' #采购部门
LET g_sql = g_sql, " AND pmdl003 = '",g_pmdl_d[g_detail_idx].pmdl003,"' "
WHEN '4' #产品分类
LET g_sql = g_sql, " AND imaa009 = '",g_pmdl_d[g_detail_idx].imaa009,"' "
WHEN '5' #料件编号
LET g_sql = g_sql, " AND pmdo001 = '",g_pmdl_d[g_detail_idx].pmdo001,"' "
END CASE {
#end add-point LET g_sql = cl_sql_add_mask(g_sql) #遮蔽特定資料
PREPARE cpmq006_pb2 FROM g_sql
DECLARE b_fill_curs2 CURSOR FOR cpmq006_pb2
END IF OPEN b_fill_curs2 USING g_enterprise,g_pmdl_d[g_detail_idx].pmdldocno LET l_ac = 1
FOREACH b_fill_curs2 INTO g_pmdl2_d[l_ac].pmdldocno,g_pmdl2_d[l_ac].pmdldocdt,g_pmdl2_d[l_ac].pmdl004,
g_pmdl2_d[l_ac].pmdl004_2_desc,g_pmdl2_d[l_ac].pmdl002,g_pmdl2_d[l_ac].pmdl002_2_desc,g_pmdl2_d[l_ac].pmdl003,
g_pmdl2_d[l_ac].pmdl003_2_desc,g_pmdl2_d[l_ac].pmdl005,g_pmdl2_d[l_ac].pmdlud002,g_pmdl2_d[l_ac].pmdlstus,
g_pmdl2_d[l_ac].pmdoseq,g_pmdl2_d[l_ac].pmdoseq1,g_pmdl2_d[l_ac].pmdoseq2,g_pmdl2_d[l_ac].pmdo003,
g_pmdl2_d[l_ac].pmdo001,g_pmdl2_d[l_ac].pmdo001_2_desc,g_pmdl2_d[l_ac].pmdo001_2_desc_1,g_pmdl2_d[l_ac].pmdo004,
g_pmdl2_d[l_ac].pmdo005,g_pmdl2_d[l_ac].pmdo006,g_pmdl2_d[l_ac].pmdo011,g_pmdl2_d[l_ac].pmdo012,
g_pmdl2_d[l_ac].pmdo013,g_pmdl2_d[l_ac].pmdo009,g_pmdl2_d[l_ac].pmdo015,g_pmdl2_d[l_ac].pmdo016,
g_pmdl2_d[l_ac].pmdo017,g_pmdl2_d[l_ac].pmdo040,g_pmdl2_d[l_ac].pmdo019,g_pmdl2_d[l_ac].pmdo024,
g_pmdl2_d[l_ac].pmdo033,g_pmdl2_d[l_ac].pmdnud001,g_pmdl2_d[l_ac].pmdn015,g_pmdl2_d[l_ac].pmdn045,
g_pmdl2_d[l_ac].pmdn049,g_pmdl2_d[l_ac].pmdn049_2_desc,g_pmdl2_d[l_ac].pmdn051,g_pmdl2_d[l_ac].pmdn051_2_desc IF SQLCA.sqlcode THEN
INITIALIZE g_errparam TO NULL
LET g_errparam.extend = "FOREACH:"
LET g_errparam.code = SQLCA.sqlcode
LET g_errparam.popup = TRUE
CALL cl_err() EXIT FOREACH
END IF #add-point:b_fill2段資料填充 name="b_fill2.fill2"
} LET g_sql = cl_sql_add_mask(g_sql) #遮蔽特定資料
PREPARE cpmq006_pb2 FROM g_sql
DECLARE b_fill_curs2 CURSOR FOR cpmq006_pb2 OPEN b_fill_curs2 LET l_ac = 1
FOREACH b_fill_curs2 INTO g_pmdl2_d[l_ac].pmdldocno,g_pmdl2_d[l_ac].pmdldocdt,g_pmdl2_d[l_ac].pmdl004,
g_pmdl2_d[l_ac].pmdl004_2_desc,g_pmdl2_d[l_ac].pmdl002,g_pmdl2_d[l_ac].pmdl002_2_desc,g_pmdl2_d[l_ac].pmdl003,
g_pmdl2_d[l_ac].pmdl003_2_desc,g_pmdl2_d[l_ac].pmdl005,g_pmdl2_d[l_ac].pmdlud002,g_pmdl2_d[l_ac].pmdlstus,
g_pmdl2_d[l_ac].pmdoseq,g_pmdl2_d[l_ac].pmdoseq1,g_pmdl2_d[l_ac].pmdoseq2,g_pmdl2_d[l_ac].pmdo003,
g_pmdl2_d[l_ac].pmdo001,g_pmdl2_d[l_ac].pmdo001_2_desc,g_pmdl2_d[l_ac].pmdo001_2_desc_1,g_pmdl2_d[l_ac].pmdo004,
g_pmdl2_d[l_ac].pmdo005,g_pmdl2_d[l_ac].pmdo006,g_pmdl2_d[l_ac].pmdo011,g_pmdl2_d[l_ac].pmdo012,
g_pmdl2_d[l_ac].pmdo013,g_pmdl2_d[l_ac].pmdo009,g_pmdl2_d[l_ac].pmdo015,g_pmdl2_d[l_ac].pmdo016,
g_pmdl2_d[l_ac].pmdo017,g_pmdl2_d[l_ac].pmdo040,g_pmdl2_d[l_ac].pmdo019,g_pmdl2_d[l_ac].pmdo024,
g_pmdl2_d[l_ac].pmdo033,g_pmdl2_d[l_ac].pmdnud001,g_pmdl2_d[l_ac].pmdn015,g_pmdl2_d[l_ac].pmdn045,
g_pmdl2_d[l_ac].pmdn049,g_pmdl2_d[l_ac].pmdn049_2_desc,g_pmdl2_d[l_ac].pmdn051,g_pmdl2_d[l_ac].pmdn051_2_desc IF SQLCA.sqlcode THEN
INITIALIZE g_errparam TO NULL
LET g_errparam.extend = "FOREACH:"
LET g_errparam.code = SQLCA.sqlcode
LET g_errparam.popup = TRUE
CALL cl_err() EXIT FOREACH
END IF
#end add-point CALL cpmq006_detail_show("'2'") CALL cpmq006_pmdn_t_mask() IF l_ac > g_max_rec THEN
INITIALIZE g_errparam TO NULL
LET g_errparam.extend = ""
LET g_errparam.code = 9035
LET g_errparam.popup = TRUE
CALL cl_err() EXIT FOREACH
END IF
LET l_ac = l_ac + 1 END FOREACH #Page2
CALL g_pmdl2_d.deleteElement(g_pmdl2_d.getLength()) #add-point:陣列長度調整 name="b_fill2.array_deleteElement" #end add-point #Page2
LET li_ac = g_pmdl2_d.getLength() DISPLAY li_ac TO FORMONLY.cnt
LET g_detail_idx2 = 1
DISPLAY g_detail_idx2 TO FORMONLY.idx #add-point:單身填充後 name="b_fill2.after_fill" #end add-point LET l_ac = li_ac END FUNCTION
T100——q查询,子母查询(汇总——明细)练习笔记的更多相关文章
- 高级查询子条件查询filter
Filter Context 在查询过程中,只判断该文档是否满足条件,只有Yes或者No { "query":{ "bool":{ //布尔关键词 " ...
- SQL语句汇总(三)——聚合函数、分组、子查询及组合查询
聚合函数: SQL中提供的聚合函数可以用来统计.求和.求最值等等. 分类: –COUNT:统计行数量 –SUM:获取单个列的合计值 –AVG:计算某个列的平均值 –MAX:计算列的最大值 –MIN:计 ...
- SQL语句汇总(三)——聚合函数、分组、子查询及组合查询
拖了一个星期,终于开始写第三篇了.走起! 聚合函数: SQL中提供的聚合函数可以用来统计.求和.求最值等等. 分类: –COUNT:统计行数量 –SUM:获取单个列的合计值 –AVG:计算某个列的平均 ...
- Django框架(九)-- 多表操作:一对一、一对多、多对多的增删改,基于对象/双下划线的跨表查询、聚合查询、分组查询、F查询与Q查询
一.创建多表模型 一对一:OneToOneField 一对多:ForeignKey 多对多:ManyToManyField 创建表时,会自动添加一个nid字段,并且自增,所以id可以不用手动创建 On ...
- Django框架(十)—— 多表操作:一对一、一对多、多对多的增删改,基于对象/双下划线的跨表查询、聚合查询、分组查询、F查询与Q查询
目录 多表操作:增删改,基于对象/双下划线的跨表查询.聚合查询.分组查询.F查询与Q查询 一.创建多表模型 二.一对多增删改表记录 1.一对多添加记录 2.一对多删除记录 3.一对多修改记录 三.一对 ...
- 【MySQL】-2 函数、分组、子查询、联合查询
函数 Mysql的函数特性没有SQL可移植性强. 大多数情况下支持的函数: 处理文本串的函数: RTrim():处理列值右边的空格 LTrim():处理列值左边的空格 Trim():处理列值的左右 ...
- MySQL(八)子查询和分组查询
一.子查询 1.子查询(subquery):嵌套在其他查询中的查询. 例如:select user_id from usertable where mobile_no in (select mobil ...
- Linq to SQL 语法查询(子查询 & in操作 & join )
var 子查询 = from c in ctx.Customers where (from o in ctx.Ord ...
- Django框架第七篇(模型层)--多表操作:一对多/多对多增删改,跨表查询(基于对象、基于双下划线跨表查询),聚合查询,分组查询,F查询与Q查询
一.多表操作 一对多字段的增删改(book表和publish表是一对多关系,publish_id字段) 增 create publish_id 传数字 (publish_id是数据库显示的字段名 ...
随机推荐
- CDQ分治的嵌套
CDQ的嵌套 上一篇博客介绍了一下CDQ的入门思想.这里再介绍一下它的进阶,CDQ套CDQ.其实如果对入门思想掌握的透彻,嵌套也是很容易掌握的,思想是一样的. 什么是嵌套 简单地说,有的问题,如果用一 ...
- Django环境搭建win(二)
Django 1.11.x 支持 Python 2.7, 3.4, 3.5 和 3.6,17年4月4号 已经发布(长期支持版本 LTS) win7下: 一.使用pip安装 1.首先要安装pip 2.p ...
- 【零基础】Selenium:Webdriver图文入门教程java篇(附相关包下载)
一.selenium2.0简述 与一般的浏览器测试框架(爬虫框架)不同,Selenium2.0实际上由两个部分组成Selenium+webdriver,Selenium负责用户指令的解释(code), ...
- cmd ora-12560协议适配器错误
这个问题我解决了很久,其实问题的关键在于我在本机安装了一个Oracle11g数据库以及安装了一个Oracle Client,导致在使用sqlplus / as sysdba链接时出现报协议适配器的错误 ...
- python操作s3 -- boto2.x
以下是python操作s3常用方法: boto s3手册:http://boto.readthedocs.org/en/latest/ref/s3.html boto s3快速入门:http://bo ...
- Qt子窗口QMidSubwindow全屏出现的问题总结
我的需求:想全屏一个子窗口QMidSubwindow,禁止显示最大化最小化和关闭按钮. 我开始尝试的是网上介绍的方法,把结果展现给大家一下,最后再总结: 方法1:QMidSubwindow直接调用sh ...
- JVM内存管理 + GC垃圾回收机制
2.JVM内存管理 JVM将内存划分为6个部分:PC寄存器(也叫程序计数器).虚拟机栈.堆.方法区.运行时常量池.本地方法栈 PC寄存器(程序计数器):用于记录当前线程运行时的位置,每一个线程都有一个 ...
- 一个Action中,可以写多个类似的业务控制方法
1)通过模块根路径 + 功能子路径 = 访问模块下子功能的路径 @Controller @RequestMapping(value="/user") public class Us ...
- SEO中常用的301永久重定向代码大全
301是永久重定向的意思,表示请求的网页已永久移动到新位置,服务器返回此响应(对 GET 或 HEAD 请求的响应)时,会自动将请求者转到新位置.其实301重定向在SEO中被广泛应用,也是被广泛认为比 ...
- k8s集群部署(3)
一.利用ansible部署kubernetes集群环境准备 基于二进制方式部署和利用ansible-playbook实现自动化:既提供一键安装脚本,也可以分步执行安装各个组件,同时讲解每一步主要参数配 ...