sql - Oracle SQL 中 CASE 中的“缺少关键字”
问题描述
我CASE
在where
子句中有这个,但是当我尝试保存时,出现“缺少关键字”错误。这样做的目的是检查是否设置a.term_date
了添加null
条件,反之亦然。:prm_date
not between b.date and c.date
代码如下:
and ( 1 = CASE
WHEN a.term_date is null then :prm_date between b.date and c.date
ELSE :prm_date not between b.date and c.date
END )
我不太确定这是否是最好的方法。
:prm_date 是用户输入的日期参数
解决方案
我想你想要:
and (
(a.term_date is null and :prm_date between b.date and c.date)
or
:prm_date not between b.date and c.date
)
略微过多的空白用于增加清晰度。
推荐阅读
- java - Is there anyway to limit the number of QueryParam?
- python - Running pgadmin throw an unexpected error
- linux - how can define the environment variable DJANGO_SETTINGS_MODULE
- rust - Memory cost of sending items over mpsc channel
- coq - How to define exp for Church Numerals in coq?
- javascript - How do I correctly reference an image in nuxt project?
- r - R: Load mypackage in vignette
- html - Django Css file unresponsive after first loading of webpage
- c# - 如何像在 C++ 中一样从内存中调用 C# 中的函数?
- php - MySQL 的 CPU 负载非常高