=> 是 Oracle 中調用 存儲過程的時候, 指定 參數名進行調用.
一般是, 某些參數有默認值的時候,你需要跳過某些參數來進行調用。
下面是具體的例子。
參數的默認值
SQL> CREATE OR REPLACE PROCEDURE HelloWorld3 (
2 p_user_name VARCHAR2,
3 p_val1 VARCHAR2 DEFAULT ' Good Moning,',
4 p_val2 VARCHAR2 DEFAULT ' Nice to Meet you'
5 ) AS
6 BEGIN
7 dbms_output.put_line('Hello ' || p_user_name || p_val1 || p_val2 || '!'
);
8 END HelloWorld3;
9 /
Procedure created.
SQL> BEGIN
2 HelloWorld3('Edward');
3 HelloWorld3('Edward', ' Good Night,');
4 HelloWorld3('Edward', ' Good Night,', 'Bye');
5 END;
6 /
Hello Edward Good Moning, Nice to Meet you!
Hello Edward Good Night, Nice to Meet you!
Hello Edward Good Night,Bye!
PL/SQL procedure successfully completed.
指定參數名稱調用
此部分使用 “參數默認值”那一小節的存儲過程。
用於說明當最后2個參數是有默認的時候,如何跳過中間那個。
SQL> BEGIN
2 HelloWorld3('Edward');
3 HelloWorld3('Edward', p_val1 => ' Good Night,');
4 HelloWorld3('Edward', p_val1 => ' Good Night,', p_val2 => 'Bye');
5 HelloWorld3('Edward', p_val2 => ' HeiHei ');
6 END;
7 /
Hello Edward Good Moning, Nice to Meet you!
Hello Edward Good Night, Nice to Meet you!
Hello Edward Good Night,Bye!
Hello Edward Good Moning, HeiHei !
PL/SQL procedure successfully completed.
