[cx-oracle-users] calling Oracle functions and getting results back
Brought to you by:
atuining
|
From: McCafferty, C. <Chr...@Dr...> - 2003-07-24 09:33:10
|
Hi,
Looking through the Aspn archives, there is discussion of returning results
from stored procedures, including Oracle procedures, but no clear-cut
example of calling a function. Is this possible using cx_oracle?
For example, if I have this function, which simply increments the number
passed in:
CREATE OR REPLACE FUNCTION TEST_FUNC(v_int in INTEGER)
RETURN NUMBER
AS
j INTEGER := NULL;
BEGIN
j := v_int + 1;
RETURN j;
END;
/
If I try to invoke it with cx_oracle, it claims the _procedure_ doesn't
exist (where mTo below is a cursor created in the normal way):
>>> mTo.callproc('TEST_FUNC', [1])
Traceback (most recent call last):
File "<stdin>", line 1, in ?
cx_Oracle.DatabaseError: ORA-06550: line 1, column 7:
PLS-00221: 'TEST_FUNC' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Do I have to use cursor.execute() instead? In which case what format should
the sql string passed to execute take?
Note that if I have a procedure that does the same thing (but doesn't
obviously return anything), then I can call it successfully.
Can anyone help?
Regards,
Chris
----------------------------------------------------------------------
If you have received this e-mail in error or wish to read our e-mail
disclaimer statement and monitoring policy, please refer to
http://www.drkw.com/disc/email/ or contact the sender.
----------------------------------------------------------------------
|