2010-10-18 121 views
2

我想编写一个Oracle PL/SQL存储过程,它将一些其他类型的对的列表作为参数,如varchar2(32)。这可能吗?什么是最好的方式来做到这一点?如何将对列表传递给Oracle存储过程?

+2

你想如何调用这个存储过程?从Java,从.net,从SQL或PL/SQL? – TTT 2010-10-18 18:45:39

回答

6

这听起来像你只是想在集合中传递,即

SQL> create type point as object (
    2 x_coordinate number, 
    3 y_coordinate number); 
    4/

Type created. 

SQL> create type point_array 
    2 is 
    3 table of point; 
    4/

Type created. 

SQL> create procedure interpolate(points IN point_array) 
    2 as 
    3 begin 
    4 null; 
    5 end; 
    6/

Procedure created. 

SQL> declare 
    2 points point_array := point_array(point(0,1), point(1,1)); 
    3 begin 
    4 interpolate(points); 
    5 end; 
    6/

PL/SQL procedure successfully completed. 

显然,在现实中,函数会做与传递的数组的东西,但这是一般的想法。

+0

你输入的速度比我快;) – APC 2010-10-18 16:58:15

+0

+1:非常好的答案和一个明确的例子 – 2010-10-18 17:01:08

+0

如果我想在程序包中定义的过程中使用'point_array',我还可以定义'point'和'point_array'那个包? – jjujuma 2010-10-18 17:01:09

相关问题