至少有3個選項:
- (標準)使用關聯數組作爲過程參數
- 定義可選形式參數
的 '足夠' 數量的
- 使用帶有定義分隔符的單個varchar參數char
示例代碼1)
TYPE t_map IS TABLE OF VARCHAR2(50) INDEX BY VARCHAR2(20);
CREATE OR REPLACE PROCEDURE demo_1 (vararg IN t_map) IS
BEGIN
/* whatever */
NULL;
END demo_1;
/* ... somewhere else ... */
my_var t_map;
my_var('first') := 'this';
my_var('next') := ' is a ';
my_var('last') := 'demo';
demo_1 (my_var);
/* ... */
示例代碼2。)(最大。 5個參數)
CREATE OR REPLACE PROCEDURE demo_2 (
vararg1 IN VARCHAR2 DEFAULT NULL
, vararg2 IN VARCHAR2 DEFAULT NULL
, vararg3 IN VARCHAR2 DEFAULT NULL
, vararg4 IN VARCHAR2 DEFAULT NULL
, vararg5 IN VARCHAR2 DEFAULT NULL
) IS
BEGIN
/* whatever */
NULL;
END demo_2;
/* ... somewhere else ... */
demo_2 ('this', ' is a ', 'demo');
/* ... */
示例代碼3。)(特殊字符存在 ';' - 不能有效載荷數據內發生)
CREATE OR REPLACE PROCEDURE demo_3 (
vararg IN VARCHAR2
) IS
l_arg2 VARCHAR2(50);
l_arg5 VARCHAR2(50);
BEGIN
l_arg2 := SUBSTR(REGEXP_SUBSTR(vararg, ';[^;]*', 1, 2), 2);
l_arg5 := SUBSTR(REGEXP_SUBSTR(vararg, ';[^;]*', 1, 5), 2);
/* whatever */
END demo_3;
/* ... somewhere else ... */
demo_3 (';this; is a ;demo;;really!;');
/* ... */
http://www.orafaq.com/usenet/comp .databases.oracle.misc/2007/02/24/0435.htm – devnull 2013-05-14 08:48:10