比较oracle SQL中的两个select语句

时间:2014-04-02 04:14:54

标签: sql shell oracle-sqldeveloper

如何比较oracle SQL中的两个select语句

select sum(quantity)
from Table 1
where order_number = XXXX

select sum(quantity)
from Table 2
where order_number = XXXX

如果数量不匹配,应用程序将回滚,如果它们匹配我需要执行更新操作。任何人都可以帮我解决如何在shell脚本中回滚并执行更新操作。

1 个答案:

答案 0 :(得分:0)

我会使用内部select语句来执行类似......

的操作
SELECT (whatever operations you gonna do) FROM dual WHERE (select sum(quantity) from Table 1 where order_number = XXXX) = (select sum(quantity) from Table 2 where order_number = XXXX);

除此之外,你也可以使用CASE。