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

发布于 2024-08-28 04:36:51 字数 192 浏览 9 评论 0原文

这两种说法有什么区别?

dbms_output.new_line(); // with no parameters.
dbms_output.new_line;    // with no parameters,no round brackets

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

真心难拥有 2024-09-04 04:36:51

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

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

有效的是空括号...

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 何时真正开始支持此约定,但我才意识到当他们引入面向对象的东西时。除非我们包含空括号,否则类型上的某些成员函数(即方法)将无法工作,例如 XMLType 的 getClobVal()。但对于标准过程调用来说,括号是严格可选的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文