您能帮我弄清楚我的更新声明出了什么问题吗?似乎执行更新查询本身太慢了。这是代码:
BEGIN
SELECT a.policy_id,
a.peril_cd,
NVL (a.ri_cd, 0) ri_cd,
e.eff_date,
e.expiry_date,
( NVL (a.premium_amt, 0)
- NVL (a.treaty_prem, 0)
- NVL (a.facul_prem, 0))
* (e.numerator_factor / e.denominator_factor) def_prem_amt,
NVL (a.share_cd, 0),
NVL (a.item_no, 0) item_no,
NVL (a.date_tag, 0) date_tag
BULK COLLECT INTO vv_policy_id,
vv_peril_cd,
vv_ri_cd,
vv_eff_date,
vv_exp_date,
vv_def_prem_amt,
vv_share_cd,
vv_item_no,
vv_date_tag
FROM GIAC_RECAP_CURR_DTL_EXT a, gipi_polbasic b, giis_line c, gipi_invoice d, giac_deferred_gross_prem_pol e --added gipi_invoice by albert 01.25.2017 (GENQA SR 5848)
WHERE a.policy_id = b.policy_id
AND b.line_cd = c.line_cd
AND a.policy_id = d.policy_id
AND a.policy_id = e.policy_id
AND a.line_cd = e.line_cd
AND a.iss_cd = e.iss_cd
AND e.extract_year = vv_ext_yy
AND e.extract_mm = v_ext_mm;
IF SQL%FOUND
THEN
FORALL indx IN 1 .. vv_policy_id.COUNT
UPDATE GIAC_RECAP_CURR_DTL_EXT
SET eff_date = vv_eff_date (indx),
exp_date = vv_exp_date (indx),
def_prem_amt = vv_def_prem_amt (indx)
WHERE policy_id = vv_policy_id (indx)
AND peril_cd = vv_peril_cd (indx)
AND ri_cd = vv_ri_cd (indx)
AND share_cd = vv_share_cd (indx)
AND item_no = vv_item_no (indx)
AND date_tag = vv_date_tag (indx);
END IF;
END;
它在下午4:08开始加载该语句,但是截至编写本(5:00 pm)时,它仍未完成执行。顺便说一下,这里是解释计划:
希望你们能帮助我。谢谢!
答案 0 :(得分:1)
通过将选择和更新组合到一个查询中,而不是在将数据填充回数据库之前将其拉出数据库之前,您会看到更好的性能。通过使用MERGE语句:
MERGE INTO giac_recap_curr_dtl_ext tgt
USING (SELECT a.policy_id,
a.peril_cd,
NVL (a.ri_cd, 0) ri_cd,
e.eff_date,
e.expiry_date,
( NVL (a.premium_amt, 0)
- NVL (a.treaty_prem, 0)
- NVL (a.facul_prem, 0))
* (e.numerator_factor / e.denominator_factor) def_prem_amt,
NVL (a.share_cd, 0),
NVL (a.item_no, 0) item_no,
NVL (a.date_tag, 0) date_tag
FROM GIAC_RECAP_CURR_DTL_EXT a, gipi_polbasic b, giis_line c, gipi_invoice d, giac_deferred_gross_prem_pol e --added gipi_invoice by albert 01.25.2017 (GENQA SR 5848)
WHERE a.policy_id = b.policy_id
AND b.line_cd = c.line_cd
AND a.policy_id = d.policy_id
AND a.policy_id = e.policy_id
AND a.line_cd = e.line_cd
AND a.iss_cd = e.iss_cd
AND e.extract_year = vv_ext_yy
AND e.extract_mm = v_ext_mm) src
ON (tgt.policy_id = src.policy_id
AND tgt.peril_cd = src.peril_cd
AND tgt.ri_cd = src.ri_cd -- should there be NVLs on the tgt side of things too?
AND tgt.share_id = src.share_id -- should there be NVLs on the tgt side of things too?
AND tgt.item_no = src.item_no -- should there be NVLs on the tgt side of things too?
AND tgt.date_tag = src.date_tag) -- should there be NVLs on the tgt side of things too?
WHEN MATCHED THEN
UPDATE SET tgt.eff_date = src.eff_dte,
tgt.exp_date = src.expiry_date,
tgt.def_prem_amt = def_prem_amt;
您可以通过从内部源子查询中删除giac_recap_curr_dtl_ext
表来提高此语句的性能,尽管我知道这样做不可能。