By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

how to use cx_Oracle callfunc

P: n/a
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.

May 11 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On May 11, 11:51 am, Godzilla <godzillais...@gmail.comwrote:
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....a1fde2069ff3da

for more info.

Thanks.

May 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.