我真的是新来的,我真的需要帮助。我正在尝试根据从另一个 select 语句连接的数据更新表。
SELECT DISTINCT A.business_unit_AP
, A.VOUCHER_ID
, A.JOURNAl_ID
, A.UNPOST_SEQ
, A.APPL_JRNL_ID
, A.PYMNT_CNT
, A.VOUCHER_LINE_NUM
, A.DISTRIB_LINE_NUM,A.dst_acct_type
, A.LEDGER
, A.PROCESS_INSTANCE
FROM PS_PROJ_RES_TMP A
LEFT OUTER JOIN ps_proj_res_cal_vw B
ON a.business_unit_ap = B.BUSINESS_UNIT_AP
AND B.PROJECT_ID = A.PROJECT_ID
AND A.ACTIVITY_ID = B.ACTIVITY_ID
AND A.RESOURCE_ID = B.RESOURCE_ID
WHERE A.SYSTEM_SOURCE ='BAP'
AND b.business_unit_ap is null*
所以基本上上面的语句从 PS_PROJ_RES_TMP 表中选择 PS_PROJ_RES_CAL_VW 中不存在的数据。我对吗?然后根据拉取的数据,我再更新 PS_VCHR_ACCTG_LINE。
我制定了这个脚本,但它花了太长时间。我最终更新了整个表格。
UPDATE PS_VCHR_ACCTG_LINE C
SET C.PC_DISTRIB_STATUS = 'N'
WHERE EXISTS
(
SELECT DISTINCT A.business_unit_AP
, A.VOUCHER_ID
, A.JOURNAl_ID
, A.UNPOST_SEQ
, A.APPL_JRNL_ID
, A.PYMNT_CNT
, A.VOUCHER_LINE_NUM
, A.DISTRIB_LINE_NUM
, A.dst_acct_type
, A.LEDGER
, A.PROCESS_INSTANCE
FROM PS_PROJ_RES_TMP A
LEFT OUTER JOIN ps_proj_res_cal_vw B
ON a.business_unit_ap = B.BUSINESS_UNIT_AP
AND B.PROJECT_ID = A.PROJECT_ID
AND A.ACTIVITY_ID = B.ACTIVITY_ID
AND A.RESOURCE_ID = B.RESOURCE_ID
WHERE b.business_unit_ap is null
AND b.PROJECT_ID is null
AND b.ACTIVITY_ID is null
AND b.RESOURCE_ID is null
AND C.BUSINESS_UNIT = a.business_unit_ap
AND C.VOUCHER_ID = A.VOUCHER_ID
AND C.unpost_seq = A.unpost_seq
AND c.appl_jrnl_id = A.appl_jrnl_id
AND c.PYMNT_CNT = A.pymnt_cnt
AND C.voucher_line_num = A.voucher_line_num
AND C.distrib_line_num = A.distrib_line_num
AND C.dst_acct_type = A.dst_acct_type
AND C.ledger = A.ledger
AND A.SYSTEM_SOURCE ='BAP'
);
我哪里做错了?非常感谢你的帮助 :)