SQL ORA-00909: 参数数目无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46837936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-00909: invalid number of arguments
提问by JD23
Maybe I am putting the parenthesis wrong or a wrong comma? I know this is a fairly novice question so I apologize in advance. I originally had this code:
也许我把括号错了或逗号错了?我知道这是一个相当新手的问题,所以我提前道歉。我最初有这个代码:
es3.last_name || ', ' ||SUBSTR(es3.first_name,1,1)
But es3 was a Left Outer Join so all the blanks were showing the ', ' so I tried this below and am getting the ERROR
但是 es3 是一个 Left Outer Join 所以所有的空白都显示了 ', ' 所以我在下面尝试了这个并且得到了错误
ORA-00909: invalid number of arguments
ORA-00909: 参数数目无效
NVL(es3.last_name, ' ' , es3.last_name || ', ' ||SUBSTR(es3.first_name,1,1))
Thanks!
谢谢!
采纳答案by Aaron Dietz
From the documentation:
从文档:
The syntax for the NVL function in Oracle/PLSQL is:
NVL( string1, replace_with )
Oracle/PLSQL 中 NVL 函数的语法是:
NVL( string1, replace_with )
You are feeding it 3 arguments, hence the error message. I believe you want this instead:
您正在为其提供 3 个参数,因此会出现错误消息。我相信你想要这个:
CASE WHEN es3.last_name IS NULL
THEN ''
ELSE es3.last_name || ', ' ||SUBSTR(es3.first_name,1,1)
END
回答by Valli
NVL can have only two arguments
NVL 只能有两个参数
NVL(String, Value )
So the above function will return 'Value' when string is null. And 'String' itself when string is not null.
所以当字符串为空时,上面的函数将返回'Value'。当字符串不为空时,'String' 本身。
Use NVL2. NVL2 can have three arguments
使用 NVL2。NVL2 可以有三个参数
NVL2(String, Value_when_not_null, Value_When_Null)
So when 'String' is not null, it returns second parameter. When String is null it returns third paramater.
因此,当 'String' 不为 null 时,它返回第二个参数。当 String 为 null 时,它返回第三个参数。
So your function should be
所以你的功能应该是
NVL2(es3.last_name||es3.first_name , es3.last_name||','||es3.first_name, ' ')
回答by Barbaros ?zhan
you must have only two arguments for
你必须只有两个论据
nvl function
nvl 功能
like in NVL(es3.last_name,'?zhan')
returns ?zhan
if es3.last_name
is null.
喜欢NVL(es3.last_name,'?zhan')
的回报?zhan
,如果es3.last_name
是空的。
i.e. problem stems from having more than two arguments.
即问题源于有两个以上的论点。
In the question problematic part is ..' ' ,
.. in
在问题中有问题的部分是' ' ,
......在
NVL(es3.last_name,
' ' ,
es3.last_name || ', ' ||SUBSTR(es3.first_name,1,1))
NVL(es3.last_name,
' ' ,
es3.last_name || ', ' ||SUBSTR(es3.first_name,1,1))