在更新oracle sql之前检查数据

在更新oracle sql之前检查数据,sql,oracle,Sql,Oracle,我想在编码这方面寻求帮助 我想在更新之前先检查此条目的数据,否则什么也不做。 例如: 换句话说,如果数据已设置为该值,则不执行任何操作,否则将更新数据 感谢您的反馈。试试以下方法: update <table> set salary = 5000 and dept_no = 1 where last_name = 'Smith' and first_name = 'John' and salary != 5000 and dept_no != 1 更新 设

我想在编码这方面寻求帮助

我想在更新之前先检查此条目的数据,否则什么也不做。 例如:

换句话说,如果数据已设置为该值,则不执行任何操作,否则将更新数据

感谢您的反馈。

试试以下方法:

update <table>
set salary = 5000 and dept_no = 1 
where last_name = 'Smith' 
and    first_name = 'John'
   and salary != 5000 
   and dept_no != 1 
更新
设置工资=5000,部门编号=1
其中姓氏='Smith'
第一个名字是“约翰”
还有薪水!=5000
和部门号!=1.

:当表中有数据时,要求看起来很突然,不做任何其他更新吗?。相反,您应该像if-if-data-exist-do-update-else-insert…如果我错了请纠正我谢谢,但是在if-else-then语句plsql代码中是否有这样做的方法?@mysticstills:这是最有效的方法。。为什么要在PLSQL中执行此操作?
update <table>
set salary = 5000 and dept_no = 1 
where last_name = 'Smith' 
and    first_name = 'John'
   and salary != 5000 
   and dept_no != 1