【发布时间】:2015-12-17 17:28:43
【问题描述】:
我在 BI 数据库中有一个包含空日期 (CREATED_ON_DT) 的表 A。我需要使用数据库链接mtl_system_items_b@afldev 使用 AFLDEV DB 中的正确日期更新这些空值。公共密钥是 AFLDEV 中的 inventory_item_id 和 BI DB 中的 integration_id。我已经构建了以下查询,但它不起作用:
UPDATE w_product_d
SET w_product_d.CREATED_ON_DT = (SELECT min(creation_date)
FROM mtl_system_items_b@afldev B
where to_char(B.inventory_item_id)=w_product_d.integration_id
and B.organization_id = '102'
AND w_product_d.CREATED_ON_DT IS NULL
and w_product_d.integration_id in (SELECT T.integration_id
FROM (SELECT * FROM w_product_d ORDER BY w_product_d.integration_id )T
WHERE T.CREATED_ON_DT IS NULL)
);
如果我运行此查询,它会将所有日期更新为空值,但我需要相反的情况发生,即用正确的日期替换空值。
请帮我解决这个问题!我在 SQL Developer for Oracle DB 上执行此操作。
【问题讨论】:
-
首先运行一个选择查询,这样您就可以看到发生了什么。然后将其转换为更新查询。
标签: sql database oracle join business-intelligence