我对SQL很陌生并且遇到了代码问题。我一直试图在表格中复制一行并替换部分记录。但是,我一直收到错误:
ORA-00907:缺少右括号
以下代码给出错误:
insert into mi_structure
select replace parent_mi_id, (child_mi_id,'GR','GR_V') child_mi_id, startdate, enddate, mutnr
from mi_structure
where parent_mi_id like 'MIPFV%29'
and sysdate between startdate and enddate;
使用以下代码的表mi_structure如下所示
select *
from mi_structure
where parent_mi_id like 'MIPFV%29'
and sysdate between startdate and enddate;
PARENT_MI_ID || CHILD_MI_ID || STARTDATE || ENDDATE || MUTNR
MIPFV_POOL 29 || CSLLXXXX.USD.GR || 42917 || 36526 || 11
我做错了什么?
答案 0 :(得分:2)
选择替换parent_mi_id,(child_mi_id,' GR',' GR_V')child_mi_id, 来自mi_structure的startdate,enddate,mutnr
看来你使用的是替换功能错误,应该如下所示
insert into mi_structure (parent_mi_id_col,child_mi_id_col,startdate_col,enddate,mutnr)
select parent_mi_id, replace(child_mi_id,'GR','GR_V') child_mi_id, startdate, enddate, mutnr
from mi_structure
where parent_mi_id like 'MIPFV%29'
and sysdate between startdate and enddate;
btw我建议您按照上面的说法在插入中添加列。
答案 1 :(得分:1)
insert into mi_structure
select parent_mi_id, replace (child_mi_id,'GR','GR_V') child_mi_id, startdate, enddate, mutnr from mi_structure
where parent_mi_id like 'MIPFV%29'
and sysdate between startdate and enddate;