DBMS_OUTPUT.NEW_LINE 和 DBMS_OUTPUT.NEW_LINE() 区别?

Vin*_*eet 5 oracle plsql oracle9i

这两种说法有什么区别?

dbms_output.new_line(); // with no parameters.
dbms_output.new_line;    // with no parameters,no round brackets
Run Code Online (Sandbox Code Playgroud)

如果存在函数重载,即使是函数名后也需要右括号和左括号。

APC*_*APC 4

区别在于第一个公式失败了,而第二个公式成功了:

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>
Run Code Online (Sandbox Code Playgroud)

编辑

起作用的是空括号......

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>
Run Code Online (Sandbox Code Playgroud)

我不知道 Oracle 何时真正开始支持此约定,但我只是在他们引入 OO 内容时才意识到这一点。除非我们包含空括号,例如 XMLType 的 ,否则类型上的某些成员函数(即方法)将无法工作getClobVal()。但对于标准过程调用来说,括号是严格可选的。