ORA-00926:缺少VALUES关键字

时间:2012-08-29 20:43:36

标签: oracle11g dbvisualizer

我已将VALUES子句移到声明中的不同位置,但没有运气。我是新手,任何帮助表示赞赏。谢谢。

INSERT INTO KEYITEM.296 (KEYVALUECHAR, KEYSETNUM)
VALUES ('NOT PUBLIC', 0)
SELECT
    KEYITEM296.KEYVALUECHAR,
    KEYITEM296.KEYSETNUM
FROM
    ITEMDATA
LEFT OUTER JOIN
    KEYITEM296
ON
    (
       ITEMDATA.ITEMNUM = KEYITEM296.ITEMNUM)
WHERE
    ITEMDATA.ITEMTYPENUM = 862 ;

2 个答案:

答案 0 :(得分:1)

我是DB2粉丝,但你不能在INSERT中混合使用VALUES和SELECT。

正确的SQL将用于INSERTing数据:

INSERT INTO KEYITEM.296 (KEYVALUECHAR, KEYSETNUM)
SELECT
    KEYITEM296.KEYVALUECHAR,
    KEYITEM296.KEYSETNUM
FROM
    ITEMDATA
LEFT OUTER JOIN
    KEYITEM296
ON
    (
       ITEMDATA.ITEMNUM = KEYITEM296.ITEMNUM)
WHERE
    ITEMDATA.ITEMTYPENUM = 862 

INSERT INTO KEYITEM.296 (KEYVALUECHAR, KEYSETNUM)
VALUES ('NOT PUBLIC', 0)

或者如果你想做INSERT然后选择SELECT:

INSERT INTO KEYITEM.296 (KEYVALUECHAR, KEYSETNUM)
VALUES ('NOT PUBLIC', 0);
SELECT
    KEYITEM296.KEYVALUECHAR,
    KEYITEM296.KEYSETNUM
FROM
    ITEMDATA
LEFT OUTER JOIN
    KEYITEM296
ON
    (
       ITEMDATA.ITEMNUM = KEYITEM296.ITEMNUM)
WHERE
    ITEMDATA.ITEMTYPENUM = 862 ;

答案 1 :(得分:0)

INSERT INTO KEYITEM296 (KEYVALUECHAR, KEYSETNUM, ITEMNUM)
VALUES ('NOT PUBLIC', 0, 862 );

  --You must complete your insert with ITEMNUM
  -- you must add ; separator
  -- you must delete '.' of your query

SELECT
    KEYITEM296.KEYVALUECHAR,
    KEYITEM296.KEYSETNUM
FROM
    ITEMDATA
LEFT OUTER JOIN
    KEYITEM296
ON
    (
       ITEMDATA.ITEMNUM = KEYITEM296.ITEMNUM)
WHERE
    ITEMDATA.ITEMTYPENUM = 862 ;