database - 合并到比赛中

标签 database oracle

我正在尝试合并到一个表中。

这个选择没有找到任何东西:

select * from dpr where dpr_qot_id=1111;

然后我像下面这样运行这个合并:

MERGE INTO dpr d
USING (select dpr_ts, dpr_qot_id
         from dpr
        where dpr_qot_id = 1111
          and dpr_ts = to_date('30.11.1999', 'DD.MM.YYYY')) s
on (s.dpr_ts = d.dpr_ts and s.dpr_qot_id = d.dpr_qot_id)
when not matched then
  insert
    (DPR_TS,
     DPR_CLOSE,
     DPR_OPEN,
     DPR_HIGH,
     DPR_LOW,
     DPR_VOLUME,
     DPR_QOT_ID)
  values
    (to_date('30.11.2010', 'DD.MM.YYYY'),
     21.66,
     21.75,
     22.005,
     21.66,
     2556.00,
     1111)
WHEN MATCHED THEN
  UPDATE
     set DPR_CLOSE  = 21.66,
         DPR_OPEN   = 21.75,
         DPR_HIGH   = 22.005,
         DPR_LOW    = 21.66,
         DPR_VOLUME = 2556.00;

这个选择仍然没有找到任何东西:

select * from dpr where dpr_qot_id=1111;

我做错了什么?

谢谢!

问候语 玛格达

最佳答案

由于在 dpr_qot_id=1111 处没有 dpr 行,您的 MATCH 的源 (USING) 查询也将不包含任何行,因此没有要合并的数据 - 因此什么都不做。

关于database - 合并到比赛中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5488336/

相关文章:

oracle - 在 'IN' 子句中使用绑定(bind)变量

linux - 运行 hello-world 的 Oracle Linux 上的 “Error response from daemon: Cannot start container … no such file or directory”

mysql - 评级表和带有评级的评论表的数据库表设计

c# - 完成队列释放速度不够快

MySQL:使用 4 周偏移量计算 4 周平均值

c# - 替代复杂主键中的 Max(ID)

Oracle 的 C# 参数化查询 - 严重而危险的错误!

c++ - 使用 OCILIB 调用带有输出变量的 Oracle 过程

c# - 将日期/时间转换为字符串时出错

.net - 各种数据库的 Entity Framework 提供程序列表