开发者

Merge and match oracle

I really need some help with my query. I am trying to merge two tables together, but I only want the data were Cast_Date and Sched_Cast_Date are the same. I try to run the query but I get the error missing keyword in the line 21 column 13. I am sure that this is not t开发者_如何学Gohe only potential error that I have. Could someone help me to get this query up and running? Below is the query that I am running.

merge into Dante5 d5
using (SELECT 
bbp.subcar treadwell, bbp.BATCH_ID batch_id,
bcs.SILICON silicon,
bcs.SULPHUR sulphur,
bcs.MANGANESE manganese,
bcs.PHOSPHORUS phosphorus,
bofcs.temperature temperature,
to_char(bbp.START_POUR, 'dd-MON-yy hh24:MI') start_pour,
to_char(bbp.END_POUR, 'dd-MON-yy hh24:MI') end_pour,
to_char(bbp.sched_cast_date, 'dd-mon-yy hh24:mi') Sched_cast_date
FROM  bof_chem_sample bcs, bof_batch_pour bbp, bof_celox_sample bofcs
WHERE bcs.SAMPLE_CODE= to_char('D1')
and bofcs.sample_code=bcs.sample_code
and bofcs.batch_id=bcs.batch_id
and bcs.batch_id = bbp.batch_id
and bofcs.temperature>0
AND bbp.START_POUR>=to_DATE('01012011000000','ddMmyyyyHH24MISS')
and bbp.sched_cast_date<=sysdate)d3
ON (d3.sched_cast_date=d5.sched_cast_date)
when matched then
delete where (d5 sched_cast_date>=to_date('18012011','ddmmyyyy'))
when not matched 
then 
update
set d5=batch_id='99999'


Your syntax is invalid to start with. If you specify WHEN MATCHED, you are required to specify WHEN MATCHED THEN UPDATE SET col=value. For the WHEN NOT MATCHED you must specify WHEN NOT MATCHED THEN INSERT. See the documentation for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜