cx_Oracle execute procedure

Discussion in 'Python' started by Poppy, Mar 19, 2008.

  1. Poppy

    Poppy Guest

    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
     
    Poppy, Mar 19, 2008
    #1
    1. Advertising

  2. Poppy

    Jerry Hill Guest

    On Wed, Mar 19, 2008 at 11:03 AM, Poppy <> wrote:
    > 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.

    --
    Jerry
     
    Jerry Hill, Mar 19, 2008
    #2
    1. Advertising

  3. Poppy wrote:

    > 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
     
    Diez B. Roggisch, Mar 19, 2008
    #3
  4. Poppy

    Poppy Guest

    Thanks Jerry and Diez. The first two replies I found answered my noob
    question.


    "Jerry Hill" <> wrote in message
    news:...
    > On Wed, Mar 19, 2008 at 11:03 AM, Poppy <>
    > wrote:
    >> 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.
    >
    > --
    > Jerry
     
    Poppy, Mar 19, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. FireListen
    Replies:
    1
    Views:
    521
    James J. Foster
    Jun 27, 2003
  2. Jeff Thur
    Replies:
    2
    Views:
    1,074
    Guest
    Feb 7, 2005
  3. Mike P
    Replies:
    0
    Views:
    3,372
    Mike P
    Jun 19, 2006
  4. Replies:
    1
    Views:
    485
  5. AlexWare
    Replies:
    2
    Views:
    786
    Paul Uiterlinden
    Oct 23, 2009
Loading...

Share This Page