英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论