neha gundre neha gundre - 2 months ago 12
MySQL Question

"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');


Not able to insert clob value, I'm getting this error


ORA-00917: missing comma


When I try to insert individual column value then I found that, error is throwing for column
cons_query
.

Answer

The problem is that you have quotes within your 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

However, the actual issue is not that a comma is missing but that you have quotes you forgot to escape. You need to write module_code = ''BC'' for example to escape those quotes (you have additional quotes in there, not just at 'BC').