"Missing comma" 在 table 中插入 clob 值时出错

"Missing comma" error while inserting clob value in table

CREATE TABLE fcc_consistency_check
(
    cons_id         VARCHAR2(30),
    cons_desc       VARCHAR2(4000),
    cons_query      CLOB,
    module_id       VARCHAR2(2),
    main_tab_name   VARCHAR2(30),
    hist_tab_name   VARCHAR2(30),
    col_name        VARCHAR2(4000),
    col_type        VARCHAR2(4000),
    check_reqd      VARCHAR2(1)
);


INSERT INTO fcc_consistency_check
VALUES ('CHK_BC003','Missing records in contract_event_log','select a.CONTRACT_REF_NO ,a.Latest_Event_Seq_No,                                                 
 c.PREV_WORKING_DAY from cstb_contract A ,sttm_dates c
 where module_code = 'BC'
 and c.Branch_code='000'
 and not exists (select * from cstb_contract_event_log B
 where a.contract_ref_no = b.contract_ref_no 
 and latest_event_seq_no = event_seq_no);',
 'BC','BCCC_EVENT_LOG_MISREC','BCCC_EVENT_LOG_MISREC_HISTORY','CONTRACT_REF_NO,LATEST_EVENT_SEQ_NO,EOD_DATE','VARCHAR2(16),NUMBER,DATE','Y');

无法插入 clob 值,出现此错误

ORA-00917: missing comma

当我尝试插入单个列值时,我发现,列 cons_query.

抛出错误

问题是您的查询中有引号:

'select a.CONTRACT_REF_NO
 ,a.Latest_Event_Seq_No,
 c.PREV_WORKING_DAY from cstb_contract A ,sttm_dates
 where module_code = 'BC'
^string starst here:
                     ^ends here, there's a commma missing

但是,实际问题不是缺少逗号,而是您忘记转义引号。例如,您需要编写 module_code = ''BC'' 来转义这些引号(您在那里有额外的引号,而不仅仅是在 'BC' 处)。