Oracle 更新多张表的脚本

huangapple go评论71阅读模式
英文:

Oracle Update script for multiple tables

问题

以下是翻译好的部分:

我正在使用这个脚本

update arinvt 
set cycle_cound_code = 'A'
where std_cost > 200, 

set cycle_count_code = 'B'
where std_cost > 100, 

set cycle_count_code 'C' 
where std_cost > 50, 
else 'D'

所以它似乎在Sap Crystal Reports中起作用,但在我的Oracle数据库中不起作用。
我收到这个错误消息:ORA-00933 SQL命令未正确结束。
我很难找出我错在哪里?
另外,如果我只运行第一行:

update arinvt 
set cycle_cound_code = 'A'
where std_cost > 200

这似乎可以工作,直到我添加了其余部分。

英文:

I am using this script

update arinvt 
set cycle_cound_code = 'A'
where std_cost > 200, 
 
set cycle_count_code = 'B'
where std_cost > 100, 

set cycle_count_code 'C' 
where std_cost > 50, 
else 'D'

So it seems it worked for Sap Crystal Reports however it will not work in my oracle database.
I am getting this error message: ORA-00933 SQL command not properly ended.
I am having trouble figuring out where I went wrong?
Also if I run the just the first line:

update arinvt 
set cycle_cound_code = 'A'
where std_cost > 200

this seems to work until I added the rest of it.

答案1

得分: 1

使用 case 表达式 代替:

update arinvt 
set cycle_cound_code =
  case when std_cost > 200 then 'A' 
       when std_cost > 100 then 'B'
       when std_cost > 50  then 'C'
       else 'D'
  end
英文:

Use a case expression instead:

update arinvt 
set cycle_cound_code =
  case when std_cost > 200 then 'A' 
       when std_cost > 100 then 'B'
       when std_cost > 50  then 'C'
       else 'D'
  end

huangapple
  • 本文由 发表于 2023年4月6日 20:26:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75949494.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定