2010-10-18 126 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

相關問題