0

I have a custom type in oracle (lro_dummy). I have also a procedure. I looks like this:

procedure dummyLro
(
    i_dummy         in  lro_dummy,
    o_dummy         out lro_dummy
)is
begin
    o_dummy := lro_dummy('asdf');
end dummyLro;

Now I want to call this procedure from python with cx_Oracle. This looks like this:

def test(db_con):
  cur = db_con.cursor()
  try:
    procedure_params = {}
    procedure_params["i_dummy"] = cur.var(cx_Oracle.OBJECT, typename="lro_dummy")
    procedure_params["o_dummy"] = cur.var(cx_Oracle.OBJECT, typename="lro_dummy")

    cur.callproc("test.dummyLro", [], procedure_params)

After that o_dummy has a value because

str(procedures_params["o_dummy"])

returns

'<cx_Oracle.OBJECT with value <cx_Oracle.Object ???.LRO_DUMMY at 0x10492c9c0>>'

But I can not access my attribute. The attribute are listed in

procedure_params["o_dummy"].type.attributes

But I can not find the value in

procedure_params["o_dummy"]

What did I wrong?

I am using Python 3.6, cx_Oracle 5.3, InstantClient 11.2, Oracle-Server 11

Lee
  • 819
  • 7
  • 32
  • What are the attributes listed in procedure_params["o_dummy"].type.attributes? – Anthony Tuininga Jun 10 '17 at 22:22
  • It returns an array of `cx_Oracle.ObjectAttribute DUMMY` with one item. The attribute `name` has the value `DUMMY` – Lee Jun 12 '17 at 06:22
  • So you should be able to access it via procedure_params["o_dummy"].DUMMY? – Anthony Tuininga Jun 12 '17 at 21:54
  • I know that it should work like this. But I got no attribute called `DUMMY`. The only attributes I have are `bufferSize`, `inconverter`, `numElements`, `outconverter`, `size` and `type`. Does it work only with special oracle-databases? Is my type (lro_dummy) incorrect? – Lee Jun 13 '17 at 04:50
  • Even if I try to create a new object of `lro_dummy` with `db_con.gettype("lro_dummy").newobject()` the only attribute I get is `type` – Lee Jun 13 '17 at 04:56

1 Answers1

0

I had the same issue. According to the "docs"(http://www.oracle.com/technetwork/articles/prez-stored-proc-084100.html) it should work the way you did it, but it did not work for me. As far as I can see, the params passed in to the proc are not mutated. Instead new objects are returned. This worked for me:

i_dummy = cursor.var(cx_Oracle.OBJECT, typename='lro_dummy')
o_dummy = cursor.var(cx_Oracle.OBJECT, typename='lro_dummy')
[something, returned_o_dummy] = cur.callproc("test.dummyLro", [], [i_dummy, o_dummy])
print(returned_o_dummy.DUMMY)
DaafVader
  • 1,735
  • 1
  • 14
  • 14