[英]Using prompts in Select Case statements
I want to use select case for my prompts. 我想在提示中使用选择大小写。 Condition is that when the prompt :4 = 'I' then prompt :5 equals all of its values, and I use the code below but i receive the following error. 条件是,当提示:4 ='I'时,提示:5等于其所有值,并且我使用下面的代码,但收到以下错误。
Error in running query because of SQL Error, Code=936, Message=ORA-00936: missing expression (50,380) 由于SQL错误而在运行查询中出现错误,代码= 936,消息= ORA-00936:缺少表达式(50,380)
2 = 2 AND (CASE :5
WHEN :4 = 'I' AND :5 = ' '
THEN :5 = '%'
END)
Anything wrong with my case statemnt? 我的案件陈述书有什么问题吗?
There are two different syntaxes for CASE
: CASE
有两种不同的语法:
CASE value1
WHEN value2 THEN expression1
WHEN value2 THEN expression2
ELSE expression3
END
and: 和:
CASE
WHEN boolean_expression THEN expression1
WHEN boolean_expression THEN expression2
ELSE expression3
END
Note: The first statement can be converted to the second as 注意:第一个语句可以转换为第二个语句
CASE
WHEN value1 = value2 THEN expression1
WHEN value1 = value3 THEN expression2
ELSE expression3
END
You are mixing these two syntaxes and it is invalid SQL. 您正在混合使用这两种语法,它是无效的SQL。
You appear to want: 您似乎想要:
:5 = CASE WHEN :4 = 'I' AND :5 = ' ' THEN '%' END
However, even that will not work as bind variables are set once and are not re-evaluated so your logic would be: 但是,即使这样也将不起作用,因为绑定变量仅设置一次且不会重新评估,因此您的逻辑将是:
( ( :4 = 'I' AND :5 = ' ' ) AND :5 = '%' )
OR ( NOT ( :4 = 'I' AND :5 = ' ' ) AND :5 = NULL )
Since :5
cannot ever be both ' '
and '%'
then that branch of the logic can never be true and anything (including NULL
) is never equal to NULL
so the second branch of the logic is also never true; 因为:5
不能同时是' '
和'%'
,所以逻辑的那个分支永远不可能为真,任何东西(包括NULL
)都永远不等于NULL
因此逻辑的第二个分支也永远不会为真; therefore your expression will never match anything. 因此,您的表情将永远不会匹配任何内容。
只需创建一个这样的表达式
decode(:4,'I',:5,SOMEVALUEORFIELD) = :5
This is your case
expression: 这是您的case
表达:
(CASE :5 WHEN :4 = 'I' AND :5 = ' ' THEN :5 = '%'
END)
I cannot figure out what you really want. 我不知道你到底想要什么。 Both the CASE :5
and the :5 = '%'
are improper. CASE :5
和:5 = '%'
都不正确。 Perhaps: 也许:
(CASE WHEN :4 = 'I' AND :5 = ' ' THEN '%'
END) as :5
However, you don't normally use parameters for column aliases. 但是,通常不使用参数作为列别名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.