1 Reply Latest reply: Nov 12, 2009 8:39 AM by 402929 RSS

    Python

    726038
      I have a simple stored procedure as such:

      create or replace procedure tdate as

      v_out number;

      begin

      select date_to_ts(sysdate)
      into v_out
      from dual;

      dbms_output.put_line(v_out);

      end;
      /

      Which returns the following from within SQL Plus:
      exec tdate;
      1257275103

      I want to know how to execute this stored procedure in a Python Script to return the
      value it returns in SQL Plus.

      Can anyone help with this.

      Also do you know of any documentation with examples of how to do this?

      Thanks in advance
        • 1. Re: Python
          402929
          If you need a return value and don't need just side efect you have to write a function

          using Cx_Oracle your script should be something like

          conn=connection(....)
          cur=conn.cursor()
          cur.execute("select WhateverFunctionYouNeed() from dual")
          row=cur.fetchone()
          cur.close()
          conn.close()

          row[0]
          # this is the value you want