oracle DBMS_OUTPUT.NEW_LINE 和 DBMS_OUTPUT.NEW_LINE() 的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2594026/
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
DBMS_OUTPUT.NEW_LINE and DBMS_OUTPUT.NEW_LINE() difference?
提问by Vineet
What is the difference between these two statements?
这两种说法有什么区别?
dbms_output.new_line(); // with no parameters.
dbms_output.new_line; // with no parameters,no round brackets
If there is function overloading,even for that close and open brackets are required after function name.
如果有函数重载,即使在函数名后也需要关闭和打开括号。
回答by APC
Well the difference is that the first formulation fails and the second one succeeds:
区别在于第一个公式失败而第二个公式成功:
SQL> begin
2 dbms_output.put_line('some text');
3 dbms_output.put('about to new_line with no parameters');
4 dbms_output.new_line;
5 end;
6 /
some text
about to new_line with no parameters
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_output.put_line('some text');
3 dbms_output.put('about to new_line with a parameter');
4 dbms_output.new_line('');
5 end;
6 /
dbms_output.new_line('');
*
ERROR at line 4:
ORA-06550: line 4, column 5:
PLS-00306: wrong number or types of arguments in call to 'NEW_LINE'
ORA-06550: line 4, column 5:
PL/SQL: Statement ignored
SQL>
edit
编辑
What does work is the empty brackets...
什么工作是空括号......
SQL> begin
2 dbms_output.put_line('some text');
3 dbms_output.put('about to new_line with a parameter');
4 dbms_output.new_line();
5 end;
6 /
some text
about to new_line with a parameter
PL/SQL procedure successfully completed.
SQL>
I don't know when Oracle actually started supprting this convention but I only became aware of it when they introduced the OO stuff. Some member functions (i.e. methods) on Types won't work unless we include the empty brackets e.g. XMLType's getClobVal()
. But the brackets are strictly optional for the standard procedural calls.
我不知道 Oracle 什么时候真正开始支持这个约定,但我是在他们引入 OO 的东西时才意识到的。除非我们包含空括号,例如 XMLType 的getClobVal()
. 但是括号对于标准过程调用是严格可选的。