cx_Oracle execute procedure

P

Poppy

I've been working on the code below and and executes silently, no
complaints, however the end result should be a record in my table and it's
not added. The procedure works with the passed credentials using SQLPlus or
SQL Developer clients. However I'm not sure if I'm constructing my python
code correctly to interact with Oracle.

I've been basing the code below on what I found in this thread
http://www.thescripts.com/forum/thread33728.html .

Zach-

import cx_Oracle

connection = cx_Oracle.connect("user/pass@server")

## PROCEDURE rptmgr.rep_utils.CLONE_REPORT( p_ordernum varchar2,p_repnum
varchar2, p_prefix number)

cur = connection.cursor()

repParams = {}
repParams['arg1'] = "5555555"
repParams['arg2'] = "2"
repParams['arg3'] = "999"

sqlStr = """BEGIN rptmgr.rep_utils.CLONE_REPORT( :arg1, :arg2, :arg3);
end;"""

cur.execute(sqlStr, repParams)

connection.commit

cur.close

connection.close
 
J

Jerry Hill

I've been working on the code below and and executes silently, no
complaints, however the end result should be a record in my table and it's
not added. The procedure works with the passed credentials using SQLPlus or
SQL Developer clients. However I'm not sure if I'm constructing my python
code correctly to interact with Oracle. ....
connection.commit
cur.close
connection.close

You have to actually call these methods:
connection.commit()
cur.close()
connection.close()

Without the parentheses, you're just getting a reference to the
methods and immediately discarding them.
 
D

Diez B. Roggisch

Poppy said:
I've been working on the code below and and executes silently, no
complaints, however the end result should be a record in my table and it's
not added. The procedure works with the passed credentials using SQLPlus
or SQL Developer clients. However I'm not sure if I'm constructing my
python code correctly to interact with Oracle.

I've been basing the code below on what I found in this thread
http://www.thescripts.com/forum/thread33728.html .

Zach-

import cx_Oracle

connection = cx_Oracle.connect("user/pass@server")

## PROCEDURE rptmgr.rep_utils.CLONE_REPORT( p_ordernum varchar2,p_repnum
varchar2, p_prefix number)

cur = connection.cursor()

repParams = {}
repParams['arg1'] = "5555555"
repParams['arg2'] = "2"
repParams['arg3'] = "999"

sqlStr = """BEGIN rptmgr.rep_utils.CLONE_REPORT( :arg1, :arg2, :arg3);
end;"""

cur.execute(sqlStr, repParams)

connection.commit

cur.close

connection.close

You forgot to call the methods using the ()-operator.

connection.commit()

and so forth.

Diez
 

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top