谁能告诉我是否可以在 oracle 中创建一个接受数组作为输入参数的存储过程以及如何创建?
Can any one tell me if its possible to create a stored procedure in oracle which accept array as an input parameter and how ?
是的.Oracle 将它们称为集合,您可以使用多种集合.
Yes. Oracle calls them collections and there's a variety of collections you can use.
使用 VARRAY 的简单数组示例.
A simple array example using a VARRAY.
DECLARE
TYPE Str_Array IS VARRAY(4) OF VARCHAR2(50);
v_array Str_Array;
PROCEDURE PROCESS_ARRAY(v_str_array Str_Array)
AS
BEGIN
FOR i IN v_str_array.first .. v_str_array.last LOOP
DBMS_OUTPUT.PUT_LINE('Hello '||v_str_array(i));
END LOOP;
END;
BEGIN
v_array := Str_Array('John','Paul','Ringo','George');
PROCESS_ARRAY(v_array);
-- can also pass unbound Str_Array
PROCESS_ARRAY(Str_Array('John','Paul','Ringo','George'));
END;
这篇关于如何在oracle中创建一个接受参数数组的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!