I want to execute an Oracle PL/SQL statement via cx_oracle in Python. Code looks like this:
db = cx_Oracle.connect(user, pass, dsn_tns)
cursor = db.cursor()
...
sel = """
DECLARE
c NUMBER := 0.2;
mn NUMBER := 1.5;
res NUMBER;
BEGIN
res := c+mn/6.;
END;
"""
try:
cursor.execute(sel)
print "PL/SQL successful executed ..."
except cx_Oracle.DatabaseError as e:
err, = e.args
print "
".join([str(err.code),err.message,err.context])
The code is running without problems, but is there any chance to get the result back to Python?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…