尝试通过一个过程执行以下查询。
当我在toad中使用单引号手动运行查询时运行良好,但在运行过程时遇到错误。
v_sql :=
'INSERT /*+ APPEND parallel(p,8)*/
INTO NDWMTR_REF_PHARM_RX_MTH
(week_id,
PHARMACY_SEQ_NBR,
SUPPLIER_ID,
FINAL_STATUS_CD,
NDW_DATA_USE_QLFR_CD,
CMF_OTLT_NBR,
CMF_OTLT_HIST_NBR,
CLAIM_CNT)
Select /*+ PARALLEL (8)*/
case
when TRIM(TO_CHAR(rx.SVC_DT, ''DAY'')) = ''FRIDAY''
THEN CAST(TO_CHAR(rx.SVC_DT, ''YYYYMMDD'') as NUMBER(8))
ELSE CAST(TO_CHAR(NEXT_DAY(rx.SVC_DT,''FRIDAY''),''YYYYMMDD'') as NUMBER(8))
END WEEK_ID,
rx.pharmacy_seq_nbr,
rx.supplier_id,
rx.final_status,
rx.ndw_data_use_qlfr_cd,
NVL(ph.CMF_OTLT_NBR,00000000) as CMF_OTLT_NBR,
NVL(rx.cmf_otlt_nbr,00000000) as cmf_otlt_hist_nbr,
count(rx.claim_id) as CLAIM_CNT
FROM
rx_fact_hdr rx
left outer JOIN V_PHARM_STORE_SEQNO_XREF ph
ON rx.pharmacy_seq_nbr = ph.PHARMACY_SEQ_NBR
where
case
when TRIM(TO_CHAR(rx.SVC_DT, ''DAY'')) = ''FRIDAY''
THEN CAST(TO_CHAR(rx.SVC_DT, ''YYYYMMDD'') as NUMBER(8))
ELSE CAST(TO_CHAR(NEXT_DAY(rx.SVC_DT,''FRIDAY''),''YYYYMMDD'') as NUMBER(8))
END = ''g_week_id''
group by
case
when TRIM(TO_CHAR(rx.SVC_DT, ''DAY'')) = ''FRIDAY''
THEN CAST(TO_CHAR(rx.SVC_DT, ''YYYYMMDD'') as NUMBER(8))
ELSE CAST(TO_CHAR(NEXT_DAY(rx.SVC_DT,''FRIDAY''),''YYYYMMDD'') as NUMBER(8))
END,
rx.pharmacy_seq_nbr,
rx.supplier_id,
rx.final_status,
rx.ndw_data_use_qlfr_cd,
ph.cmf_otlt_nbr,
rx.cmf_otlt_nbr';
EXECUTE IMMEDIATE v_sql;
ORA-00907:缺少右括号
答案 0 :(得分:3)