how to use cx_Oracle callfunc

Godzilla godzillaismad at gmail.com
Thu May 10 21:51:19 EDT 2007


Hi all,

I need to know how to use the method callfunc in cx_Oracle. I am
trying to get a primary key after an insert via a function call, but I
do not know how to pass the return value from the function via the
callfunc method. Can anyone help?

I also tried the execute(), and callproc(), but to no avail. My
function is as below:

create or replace function addRow(desc table1.col1%type) return number
is id number;
begin
  insert into table1 (description) values (desc) returning table1ID
into id;
  return(id);
  exception
    when others then return(-1)
end;

The code in the callfunc:

cur.callfunc("addRow", returnType, param)

Question is:
- What is returnType and how to I declare that before passing into the
function?
- How do I define the parameters?

I tried the setinputsizes and setoutputsize, but I keep getting errors
saying the parameter is incorrectly defined. Please help. Thank.




More information about the Python-list mailing list