2016-03-15 76 views
-4

我在試圖弄清楚這個SQL插入語句究竟出了什麼問題時真的很困難。SQL插入錯誤:ORA-00936

INSERT INTO mpcs.shop_inventory (
    SI_KEY, 
    INV_TYPE, 
    MTI_PART_NO, 
    BUILD_NO, 
    SERIAL_NO, 
    HOME_LOCATION, 
    HOME_LOCATION_SUB, 
    DESCRIPTION, 
    CATEGORY, 
    QUANTITY, 
    MIN_QTY, 
    CONSUMABLE, 
    CUST_PART_NO, 
    UOM, 
    WEIGHT, 
    SCRAP_FLAG, 
    NEXT_CAL, 
    INTERVAL, 
    SIZE_1, 
    SIZE_2, 
    SIZE_3 
    ) 
VALUES (
    28990, 
    'TEST', 
    '01400010002', 
    0, 
    '0', 
    'DEPT-850', 
    'DEPT-850', 
    'Test', 
    '001', 
    1, 
    0, 
    0, 
    '', 
    'BOTTLES', 
    '3', 
    0, 
    to_date('27-June-2008', 'DD-MON-YYYY'), 
    0, 
    , 
    , 
    ) 
+4

。 ''''最後你的逗號不是有效的語法 – Mihai

+3

我沒有Oracle專家,但我確信你不能只添加逗號而沒有東西作爲一個值(見你的語句結尾)。你需要包括一些東西。 – Igor

回答

2

一樣的意見建議,請嘗試更改您的,,,發送NULL值而不是

INSERT INTO mpcs.shop_inventory (
    SI_KEY, 
    INV_TYPE, 
    MTI_PART_NO, 
    BUILD_NO, 
    SERIAL_NO, 
    HOME_LOCATION, 
    HOME_LOCATION_SUB, 
    DESCRIPTION, 
    CATEGORY, 
    QUANTITY, 
    MIN_QTY, 
    CONSUMABLE, 
    CUST_PART_NO, 
    UOM, 
    WEIGHT, 
    SCRAP_FLAG, 
    NEXT_CAL, 
    INTERVAL, 
    SIZE_1, 
    SIZE_2, 
    SIZE_3 
    ) 
VALUES (
    28990, 
    'TEST', 
    '01400010002', 
    0, 
    '0', 
    'DEPT-850', 
    'DEPT-850', 
    'Test', 
    '001', 
    1, 
    0, 
    0, 
    '', 
    'BOTTLES', 
    '3', 
    0, 
    to_date('27-June-2008', 'DD-MON-YYYY'), 
    0, 
    NULL, 
    NULL, 
    NULL 
    ) 
+2

不,你希望在最後有3個空值,或者'列數'不匹配值。 21欄,20個值。 – xQbert

+0

啊,對不起。剛剛編輯 –

0
Can use directly the columns you want to insert only in insert statement: 

    INSERT INTO mpcs.shop_inventory (
     SI_KEY, 
     INV_TYPE, 
     MTI_PART_NO, 
     BUILD_NO, 
     SERIAL_NO, 
     HOME_LOCATION, 
     HOME_LOCATION_SUB, 
     DESCRIPTION, 
     CATEGORY, 
     QUANTITY, 
     MIN_QTY, 
     CONSUMABLE, 
     CUST_PART_NO, 
     UOM, 
     WEIGHT, 
     SCRAP_FLAG, 
     NEXT_CAL, 
     INTERVAL 
     ) 
    VALUES (
     28990, 
     'TEST', 
     '01400010002', 
     0, 
     '0', 
     'DEPT-850', 
     'DEPT-850', 
     'Test', 
     '001', 
     1, 
     0, 
     0, 
     '', 
     'BOTTLES', 
     '3', 
     0, 
     to_date('27-June-2008', 'DD-MON-YYYY'), 
     0 
     ); 

Just keep it simple. 
如果要插入空值,無論是使用空字符串