0

我正在尝试将此更新语句添加到前面有几个插入语句的存储过程中。我在尝试编译时收到 ORA-00933,但没有发现任何问题。我会说我已经习惯了 SQL Server,所以如果这在翻译到 Oracle 方面有些愚蠢,请原谅我。

UPDATE
  APEX_QC_TLINK_AGENTS
SET
  I_FK_TLINK_TEAM = SHG_DATAW.APEX_QC_TLINK_TEAMS.I_SK_TLINK_TEAM
FROM
  SHG_DATAW.APEX_QC_TLINK_AGENTS
LEFT JOIN
  CMS_W_AGENT_DETAILS@SHG_SPECIALIST
  ON
    SHG_DATAW.APEX_QC_TLINK_AGENTS.A_FORENAME = CMS_W_AGENT_DETAILS.FIRST_NAME
    AND
    SHG_DATAW.APEX_QC_TLINK_AGENTS.A_SURNAME = CMS_W_AGENT_DETAILS.LAST_NAME
LEFT JOIN
  SHG_DATAW.APEX_QC_TLINK_TEAMS
  ON 
    CMS_W_AGENT_DETAILS.TEAM_NAME = SHG_DATAW.APEX_QC_TLINK_TEAMS.A_TEAMNAME
WHERE
  SHG_DATAW.APEX_QC_TLINK_TEAMS.I_SK_TLINK_TEAM <> APEX_QC_TLINK_AGENTS.I_FK_TEAM;

如果有人需要,我可以提供(如果需要)整个存储过程。

非常感谢一如既往:)

马库斯

4

1 回答 1

1

Oracle 不支持UPDATE... FROMSQL Server 所支持的构造。您应该改用MERGE 语句。它应该是这样的:

MERGE INTO APEX_QC_TLINK_AGENTS A
USING
(
SELECT SHG_DATAW.APEX_QC_TLINK_TEAMS.I_SK_TLINK_TEAM
FROM
  SHG_DATAW.APEX_QC_TLINK_AGENTS
LEFT JOIN
  CMS_W_AGENT_DETAILS@SHG_SPECIALIST
  ON
    SHG_DATAW.APEX_QC_TLINK_AGENTS.A_FORENAME = CMS_W_AGENT_DETAILS.FIRST_NAME
    AND
    SHG_DATAW.APEX_QC_TLINK_AGENTS.A_SURNAME = CMS_W_AGENT_DETAILS.LAST_NAME
LEFT JOIN
  SHG_DATAW.APEX_QC_TLINK_TEAMS
  ON 
    CMS_W_AGENT_DETAILS.TEAM_NAME = SHG_DATAW.APEX_QC_TLINK_TEAMS.A_TEAMNAME

) B
ON (B.I_SK_TLINK_TEAM <> A.I_FK_TEAM)
WHEN MATCHED THEN
UPDATE SET A.I_FK_TLINK_TEAM = B.I_SK_TLINK_TEAM;
于 2012-11-27T16:52:03.973 回答