用减号插入表格

时间:2016-10-06 06:52:37

标签: sql oracle

我正在尝试使用减号操作将一些数据插入到表中。我有我的表(SG_AN_KZ)和一个stag表,我用它来检索一些数据来做减号。我还从内部联接中检索数据以进行减号操作。问题是查询不起作用,我无法弄清楚原因。这里是整个查询:

INSERT INTO SG_AN_KZ (ID, CODE, TIPO_RECORD, SYSCREATEDATE, SYSCREATEUSER, SYSUPDATEDATE, SYSUPDATEUSER, FLAG_DELETED, ID_PN) 
 (SELECT (SELECT ROWNUM + ID_KZ, CODE, TIPO_RECORD, systimestamp, 967, systimestamp, 967, 0, ID_PN) FROM
     (SELECT Q1.CODE, Q1.TIPO_RECORD, systimestamp, 967, systimestamp, 967,0,Q2.ID
      FROM
       (SELECT DISTINCT S.CODE, S.TIPO_RECORD FROM STAG_SG_AN_KZ S
       INNER JOIN SG_AN_PN P 
       ON P.CODE = S.CODE)Q1,
       (SELECT DISTINCT P.ID FROM SG_AN_PN P
       INNER JOIN STAG_SG_AN_KZ S
       ON S.CODE = P.CODE) Q2,
       STAG_SG_AN_KZ S 
      WHERE S.CODE = Q1.CODE)  
     MINUS
     SELECT CODE, TIPO_RECORD, ID_PN from SG_AN_KZ; 

Errore(118,2): PL/SQL: SQL Statement ignored
Errore(119,99): PL/SQL: ORA-00923: parola chiave FROM non trovata dove prevista
你知道吗? 提前谢谢你。

0 个答案:

没有答案