これら2つのステートメントの違いは何ですか?
dbms_output.new_line(); // with no parameters.
dbms_output.new_line; // with no parameters,no round brackets
関数のオーバーロードがある場合でも、関数名の後に閉じ括弧と開き括弧が必要です。
違いは、最初の定式化が失敗し、2 番目の定式化が成功することです。
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>
オラクルが実際にこの規則をサポートし始めた時期はわかりませんが、私は彼らが OO を導入したときに初めてそれに気付きました。XMLType のgetClobVal()
. ただし、標準の手続き呼び出しでは、括弧は厳密にオプションです。