gpt4 book ai didi

oracle - DBMS_OUTPUT.NEW_LINE 和 DBMS_OUTPUT.NEW_LINE() 的区别?

转载 作者:行者123 更新时间:2023-12-01 02:57:02 24 4
gpt4 key购买 nike

这两种说法有什么区别?

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 的 getClobVal() .但是括号对于标准过程调用是严格可选的。

关于oracle - DBMS_OUTPUT.NEW_LINE 和 DBMS_OUTPUT.NEW_LINE() 的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2594026/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com