在 oracle 中更新多行
我想通过使用硬编码值来更新表值。这是我的代码:
BEGIN
UPDATE emp_table
SET expiry_dt = TO_DATE('21.09.2009:00:00:01','DD.MM.YYYY:HH24:MI:SS'),
WHERE emp_id = '78629160';
UPDATE emp_table
SET expiry_dt = TO_DATE('21.09.2009:00:00:01','DD.MM.YYYY:HH24:MI:SS'),
WHERE emp_id = '78629160';
END
我想在单个更新语句中执行此操作。谁能告诉我解决方案吗?
I want to update the table values by using hard coded values.here is my code :
BEGIN
UPDATE emp_table
SET expiry_dt = TO_DATE('21.09.2009:00:00:01','DD.MM.YYYY:HH24:MI:SS'),
WHERE emp_id = '78629160';
UPDATE emp_table
SET expiry_dt = TO_DATE('21.09.2009:00:00:01','DD.MM.YYYY:HH24:MI:SS'),
WHERE emp_id = '78629160';
END
I want to do it in the single update statement. Can anyone tell me the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
应该做你。使用不同的员工 ID 编辑 IN 子句,因为您的 ID 是相同的。
Should do you. Edited the IN clause with various employee id's as yours were identical.
我认为您两次拥有相同 ID 的事实只是复制和粘贴错误,就像两个日期相同的事实一样。
顺便说一句:
emp_id
是什么数据类型?如果这是数字类型,请去掉文字的单引号(数字文字不应加引号)。它们将阻止在该列上使用索引!I assume the fact that you have the same ID twice was just a copy and paste error, just like the fact that both dates are identical.
Btw: what data type is
emp_id
? If that is a numeric type, get rid of the single quotes for the literals (numeric literals should not be quoted). They will prevent the usage of an index on that column!开始 UPDATE emp_table SET expiry_dt = TO_DATE ('21.09.2009:00:00:01','DD.MM.YYYY:HH24:MI:SS'),-- 为什么你在这里使用 ',' ?
WHERE emp_id = '78629160';
开始
UPDATE emp_table SET expiry_dt = TO_DATE('21.09.2009:00:00:01','DD.MM.YYYY:HH24:MI:SS')
WHERE emp_id = '78629160';
结尾;
它在我的机器上运行,没有任何错误和问题..并且也给出了预期的结果..
请再试一次,不要使用“,”。
Begin UPDATE emp_table SET expiry_dt = TO_DATE ('21.09.2009:00:00:01','DD.MM.YYYY:HH24:MI:SS'),-- why you are using ',' here??
WHERE emp_id = '78629160';
Begin
UPDATE emp_table SET expiry_dt = TO_DATE('21.09.2009:00:00:01','DD.MM.YYYY:HH24:MI:SS')
WHERE emp_id = '78629160';
end;
It is running in my machine whithout any error and problem.. adn giving expected result also..
try once again without using that ','.