【问题标题】:SQL Error: ORA-00917: missing comma 00917. 00000 - "missing comma" *Cause: *Action:SQL 错误:ORA-00917:缺少逗号 00917。00000 -“缺少逗号” *原因:*操作:
【发布时间】:2020-10-25 23:16:06
【问题描述】:

我正在尝试将新行添加到 Products 表中:

INSERT INTO Products_mgs( product_id,category_id,product_code,product_name,
description,list_price,discount_percent,date_added)
VALUES ( 11, 4,'YDP162R','Yamaha Arius YDP162R Traditional Console Style Digital Piano',
'The best keyboard on the market. Offers excellent sound rendering
 that truly separates it from the rest of the pack.',1599.99,10,'2020-10-25'()));

但我不断收到此错误消息:

命令行错误:23 列:77 错误报告 - SQL 错误: ORA-00917: 缺少逗号 00917. 00000 - “缺少逗号” *原因:
*行动:

【问题讨论】:

    标签: sql oracle insert-statement


    【解决方案1】:

    语句末尾有多余的括号,没有任何意义。我还建议对列 date_added 使用显式文字日期,而不是依赖隐式转换(当然,假设该列是 date 数据类型)。

    所以:

    INSERT INTO Products_mgs (
        product_id, 
        category_id, 
        product_code, 
        product_name, 
        description, 
        list_price, 
        discount_percent, 
        date_added
    ) VALUES (
        11, 
        4, 
        'YDP162R', 
        'Yamaha Arius YDP162R Traditional Console Style Digital Piano',
        'The best keyboard on the market. Offers excellent sound rendering that truly separates it from the rest of the pack.',
        1599.99,
        10,
        DATE '2020-10-25'   --> literal date
    );  -- trailing parentheses removed
    

    【讨论】:

      猜你喜欢
      • 2015-11-21
      • 1970-01-01
      • 2018-01-10
      • 1970-01-01
      • 1970-01-01
      • 2013-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多