本文介绍了sql错误ora 00905在oracle sql开发人员的case语句中缺少关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 使用 Sqltmp as ( 选择计数(*) as cnt 来自员工其中 age 是 null 和 rownum< = 2 ) 选择 案例 何时 cnt> 0 然后 假脱机 Filepath 从员工 Empid >其中 rownum< = 10; 假脱机 off ; 否则 假脱机 filepath 从员工 Empid >其中 rownum< = 10; 假脱机 off ; 结束 从 Sqltmp 我在罢工部分收到错误如 sql error ora 00905缺少关键字 i无法解决此错误。 请注意以上声明中的错误是什么? 谢谢解决方案 你不能在CASE语句中做到这一切。它不是像C#这样的编程语言。 参见http://docs.oracle.com/cd/B19306_01/server.102/b14200/expressions004.htm [ ^ ] 我不确定你是什么重新尝试查询但是如果你想要查询结果只是在你的查询之前启动假脱机并最终停止它,比如 假脱机 Filepath 使用 Sqltmp as ( 选择计数(*) as cnt 来自员工其中 age 是 null 和 rownum< = 2 ) 选择 case 当 cnt> 0 然后 从员工中选择 Empid 其中 rownum< = 10; 其他 选择 Empid 来自员工其中 rownum< = 10; 结束 来自 Sqltmp 后台打印 off ; 但是,由于你有单独的语句,所以不能正常运行,所以也许你打算做一个标量查询。类似 假脱机 文件路径 使用 Sqltmp as ( 选择计数(*)作为 cnt 来自 employee 其中 age null 和 rownum< = 2 ) 选择 case 当 cnt< 0 然后 (从员工中选择 Empid 其中 rownum< = 10 ) 否则 (选择 Empid 来自员工其中 rownum< = 10) 结束 来自 Sqltmp 假脱机 off ; 但是我仍然不明白为什么两个案例分支中的select都相同,以及为什么在WITH子句中只选择2行... Hi,With Sqltmpas( Select Count(*) as cnt from employee where age is null and rownum<=2)Select case When cnt>0 Then Spool "Filepath" Select Empid from employee where rownum<=10; Spool off; Else Spool "filepath" Select Empid from employee where rownum<=10; Spool off; EndFrom SqltmpI'm getting error in strike part likesql error ora 00905 missing keywordi cannot able to troubleshoot this error.Please suggest what is the error in above statement?Thanks 解决方案 You can't do all that in a CASE statement. It is not a programming language like C#.See http://docs.oracle.com/cd/B19306_01/server.102/b14200/expressions004.htm[^]I'm not sure what you're trying to query but if you want to spool the result just start spool before your query and stop it in the end, likeSpool "Filepath"With Sqltmpas( Select Count(*) as cnt from employee where age is null and rownum<=2)Select case When cnt>0 Then Select Empid from employee where rownum<=10; Else Select Empid from employee where rownum<=10; EndFrom SqltmpSpool off;However, what wont run properly since you have separate statements in case so perhaps you meant to do a scalar query. SOmething likeSpool "Filepath"With Sqltmpas( Select Count(*) as cnt from employee where age is null and rownum<=2)Select case When cnt<0 Then (Select Empid from employee where rownum<=10) Else (Select Empid from employee where rownum<=10) EndFrom SqltmpSpool off;However I still don't understand why the select is the same in both case branches and why you select only 2 rows in the WITH clause... 这篇关于sql错误ora 00905在oracle sql开发人员的case语句中缺少关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-31 00:53