Note that there are some explanatory texts on larger screens.

plurals
  1. POcx_oracle: can callfunc return list?
    primarykey
    data
    text
    <p>I'm trying to write a PL/SQL function that returns an array of integers and then be able to call it with cx_Oracles callfunc. I think I got the PL/SQL function right, but I don't know how to call it with cx_Oracle.</p> <p><code>create or replace type test_type is table of NUMBER(10);</code></p> <pre><code>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; </code></pre> <p>It works with sqlplus:</p> <pre><code>SQL&gt; 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) </code></pre> <p>How can I get the result of such function using cx_Oracle? Is that possible?</p> <p>I've found this <a href="http://osdir.com/ml/python.db.cx-oracle/2005-06/msg00014.html" rel="nofollow">http://osdir.com/ml/python.db.cx-oracle/2005-06/msg00014.html</a> but I don't realy know how to use it. When I change my type definition to:</p> <pre><code>create or replace type test_type is table of NUMBER(10) index by binary_integer; </code></pre> <p>I get: Warning: Type created with compilation errors.</p> <pre><code>SQL&gt; 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 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload