“ SQL命令未正确结束”-插入语句

时间:2018-07-13 20:59:37

标签: sql oracle

运行该语句时出现以下错误,

[sql] Failed to execute:  
INSERT INTO REPORT ( 
                   ID
                 , CI
                 , TECHNOLOGY
                 , MAJOR_VERSION
                 , MINOR_VERSION
                 , PATCH_LEVEL
                 , INSTALL_DATE
                 , INSTALLED_BY
                 , TASK ) values ( 
                                 REPORT_ID_SEQ.nextval
                               , 'host1'
                               , 'Apple card'
                               , 'N/A'
                               , 'N/A'
                               , '12233'
                               , SYSTIMESTAMP
                               , 'test@gmail.com'
                               , '' ) FROM dual
  

执行SQL脚本时出错:java.sql.SQLSyntaxErrorException:   ORA-00933:SQL命令未正确结束

2 个答案:

答案 0 :(得分:4)

您最后不需要from dual,因为您没有使用任何SELECT语句。

您可以执行SELECTVALUES来插入值:

使用SELECT

INSERT INTO report 
            ( 
                    id, 
                    ci, 
                    technology, 
                    major_version, 
                    minor_version, 
                    patch_level, 
                    install_date, 
                    installed_by, 
                    task 
        ) 
SELECT     
                        report_id_seq.nextval, 
                        'host1', 
                        'Apple card', 
                        'N/A', 
                        'N/A', 
                        '12233', 
                        systimestamp, 
                        'test@gmail.com', 
                        '' 
from        dual;

使用值

INSERT INTO report 
            ( 
                        id, 
                        ci, 
                        technology, 
                        major_version, 
                        minor_version, 
                        patch_level, 
                        install_date, 
                        installed_by, 
                        task 
            ) 
            VALUES 
            ( 
                        report_id_seq.nextval, 
                        'host1', 
                        'Apple card', 
                        'N/A', 
                        'N/A', 
                        '12233', 
                        systimestamp, 
                        'test@gmail.com', 
                        '' 
            ) ;

答案 1 :(得分:-1)

从双重删除 并最后添加;