整数の配列を返し、cx_Oracles callfunc で呼び出すことができる PL/SQL 関数を作成しようとしています。PL/SQL 関数は正しく取得できたと思いますが、cx_Oracle で呼び出す方法がわかりません。
create or replace type test_type is table of NUMBER(10);
create or replace function test_function (n in INTEGER)
RETURN test_type
AS
tmp_tab test_type := test_type();
BEGIN
tmp_tab.EXTEND(n);
FOR i IN 1 .. n LOOP
tmp_tab(i) := i;
END LOOP;
RETURN tmp_tab;
END;
それはsqlplusで動作します:
SQL> select test_function(20) from dual;
TEST_FUNCTION(20)
--------------------------------------------------------------------------------
TEST_TYPE(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
cx_Oracle を使用してそのような関数の結果を取得するにはどうすればよいですか? それは可能ですか?
http://osdir.com/ml/python.db.cx-oracle/2005-06/msg00014.htmlを見つけましたが、使い方がよくわかりません。型定義を次のように変更すると:
create or replace type test_type is table of NUMBER(10) index by binary_integer;
私は得る:警告:コンパイルエラーで作成された型。
SQL> sho err
Errors for TYPE TEST_TYPE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
1/19 PLS-00355: use of pl/sql table not allowed in this context