【问题标题】:Oracle - Updating with Join 3 tablesOracle - 使用加入 3 个表进行更新
【发布时间】:2021-05-04 22:48:58
【问题描述】:

我有 3 个表:inventory 作为表 1,buy_transaction 作为表 2,po_data 作为表 3。

这些是我尝试过的查询:

update vnt_inventory_tab.quantity
set vnt_inventory_tab.quantity = quantity + (SELECT pdt.quantity
FROM   vnt_po_data_tab pdt JOIN vnt_buy_trnsctn_tab bt ON pdt.po_no = bt.po_no
WHERE  pdt.po_no = :p_po_no)
where VNT_INVENTORY_TAB.CODE = VNT_PO_DATA_TAB.CODE;

它返回表不存在。我不确定我在哪里做错了,因为当我执行子查询时,它会准确返回我想要更新到库存中的数字。

请帮帮我

【问题讨论】:

  • 请显示完整的错误信息。
  • [错误] 执行 (1: 76): ORA-00942: 表或视图不存在
  • 更新 vnt_inventory_tab.quantity -> 更新 vnt_inventory_tab
  • 看起来最终条件 vnt_inventory_tab.code = vnt_po_data_tab.code 属于子查询,因为 vnt_inventory_tab 没有名为 vnt_po_data_tab.code 的列。

标签: plsql oracle11g plsqldeveloper


【解决方案1】:

在关键字更新后,语法 UPDATE 语句只需要 table-Name(不是像您这样的特定列)。更多详情见Oracle docs

【讨论】:

    猜你喜欢
    • 2018-02-24
    • 1970-01-01
    • 1970-01-01
    • 2019-07-01
    • 1970-01-01
    • 2011-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多