how to use cx_Oracle callfunc

G

Godzilla

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.
 
G

Godzilla

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.

Hello,

found a solution in another thread... see

http://groups.google.com/group/comp...o+setinputsizes&rnum=9&hl=en#4ca1fde2069ff3da

for more info.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top