How to call a stored procedure?

Victor Muslin victor at prodigy.net
Tue Jan 16 17:31:06 EST 2001


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