这两种说法有什么区别?
dbms_output.new_line(); // with no parameters.
dbms_output.new_line; // with no parameters,no round brackets
如果有函数重载,即使是在函数名之后也需要右括号和左括号。
不同的是,第一个公式失败了,第二个公式成功了:
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>
编辑
有效的是空括号......
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>
我不知道 Oracle 什么时候真正开始支持这种约定,但我只是在他们引入 OO 的东西时才意识到这一点。除非我们包含空括号,例如 XMLType's ,否则类型上的某些成员函数(即方法)将不起作用getClobVal()
。但是对于标准程序调用,括号是严格可选的。