Error: ORA-00907: missing right parenthesis - can you help figure out issue

前端 未结 1 710
忘了有多久
忘了有多久 2021-01-23 07:11
select regexp_substr((replace(replace(replace((\'CA\',\'CO\',\'IL\',\'KS\'),chr(40)),chr(41)), chr(39))), \'[^,]+\', 1, level) as division from dual
                             


        
1条回答
  •  盖世英雄少女心
    2021-01-23 07:47

    You have a quotation problem(quote the whole term ('CA','CO','IL','KS') after adding extra quotes per each single quote), try this rather :

     SELECT regexp_substr((replace(replace(replace('(''CA'',''CO'',''IL'',''KS'')',
                          chr(40)),
                          chr(41)), 
                          chr(39))), '[^,]+', 1, level) AS division 
       FROM dual
    CONNECT BY level <= regexp_count('(''CA'',''CO'',''IL'',''KS'')', ',') + 1;
    
    DIVISION
    --------
    CA
    CO
    IL
    KS
    

    Demo

    0 讨论(0)
提交回复
热议问题