How to call a stored procedure?

Victor Muslin victor at prodigy.net
Wed Jan 17 09:54:52 EST 2001


Thanks to everyone for your help. For those who may come across the
same problem the answer for Oracle via ODBC is:

cur.execute("{call delete_server(1)}")

Apparently had to use "call" instead of "execute" and had to use { }
around the statement!

On Tue, 16 Jan 2001 22:31:06 GMT, victor at prodigy.net (Victor Muslin)
wrote:

>I am using Python 1.5.2 on WindowsNT.
>
>I have a stored procedure defined in Oracle:
>
>CREATE OR REPLACE PROCEDURE DELETE_SERVER
>(
>        SERVER_ID_ARG   IN NUMBER
>)
>AS
>BEGIN
>        DELETE FROM SERVER WHERE SERVER_ID = SERVER_ID_ARG;
>COMMIT;
>END DELETE_SERVER;
>/
>
>Calling it from SQLPLUS works file:
>
>	SQL> execute delete_server(1);
>
>However when I try calling it from Python it gives me an error. Here's
>the Python program:
>
>import dbi, odbc
>import sys
>cs = 'db/user/password'
>
>dbconn = odbc.odbc(cs)
>cur = dbconn.cursor()
>cur.execute("execute vmuslin.delete_adserver(3)");
>
>
>The error I get is:
>
>Traceback (innermost last):
>  File "E:\dev\dclk\eng\src\apps\ADMIN_~1\xx.py", line 7, in ?
>    cur.execute("execute vmuslin.delete_adserver(3)");
>dbi.program-error: [Microsoft][ODBC driver for
>Oracle][Oracle]ORA-00900: invalid SQL statement in EXEC
>
>Is it not possible to call stored procedures from Python?




More information about the Python-list mailing list