使用双连接进行更新

时间:2014-08-26 01:47:51

标签: sql oracle ms-access

我有一个访问查询,我需要转换为Oracle。在访问中,它使用内部联接内部联接。我不是这方面的专家,但我只是在某种程度上学习了Oracle而且几乎没有任何访问权限。 (并且不是我的访问字符串(它的创建者在一年前去世))。我没有选择转换到oracle ......它只是需要完成。 :/

无论如何......这是字符串:

UPDATE AIRMODEL_NETWORK_SUMMARY
  INNER JOIN (HISTORY_BOL
    INNER JOIN PERIOD_TO_PROCESS
    ON
      (HISTORY_BOL.FSCL_WK_IN_YR_NUM = PERIOD_TO_PROCESS.FSCL_WK_IN_YR_NUM)
    AND
      (HISTORY_BOL.FSCL_YR_NUM = PERIOD_TO_PROCESS.FSCL_YR_NUM)
      )
  ON
    (AIRMODEL_NETWORK_SUMMARY.LOC_ID = HISTORY_BOL.TO_LOC_ID)
  AND
    (AIRMODEL_NETWORK_SUMMARY.FSCL_WK_IN_YR_NUM = HISTORY_BOL.FSCL_WK_IN_YR_NUM)
  AND
    (AIRMODEL_NETWORK_SUMMARY.FSCL_YR_NUM = HISTORY_BOL.FSCL_YR_NUM)
SET AIRMODEL_NETWORK_SUMMARY.CASES_RCVD = TOTAL_BOL_SHIP_CASE_QTY;

1 个答案:

答案 0 :(得分:1)

Oracle喜欢它:

MERGE
INTO    AIRMODEL_NETWORK_SUMMARY
USING   (
  SELECT TOTAL_BOL_SHIP_CASE_QTY, ROWID AS r 
  FROM AIRMODEL_NETWORK_SUMMARY
  INNER JOIN HISTORY_BOL
  ON
    (AIRMODEL_NETWORK_SUMMARY.LOC_ID = HISTORY_BOL.TO_LOC_ID)
  AND
    (AIRMODEL_NETWORK_SUMMARY.FSCL_WK_IN_YR_NUM = HISTORY_BOL.FSCL_WK_IN_YR_NUM)
  AND
    (AIRMODEL_NETWORK_SUMMARY.FSCL_YR_NUM = HISTORY_BOL.FSCL_YR_NUM)
  INNER JOIN PERIOD_TO_PROCESS
    ON
      (HISTORY_BOL.FSCL_WK_IN_YR_NUM = PERIOD_TO_PROCESS.FSCL_WK_IN_YR_NUM)
    AND
      (HISTORY_BOL.FSCL_YR_NUM = PERIOD_TO_PROCESS.FSCL_YR_NUM)
)
ON      (rowid = r)
WHEN MATCHED THEN
UPDATE
SET     CASES_RCVD = TOTAL_BOL_SHIP_CASE_QTY;