Oracle
 sql >> Database >  >> RDS >> Oracle

Come chiamare correttamente la funzione memorizzata fnd_concurrent.wait_for_request tramite l'API del modulo cx_Oracle?

Non ho visto un errore con questo test case:

import cx_Oracle
import os
import sys

"""

create or replace function my_wait_for_request
  (request_id IN number default NULL,
          interval   IN number default 60,
          max_wait   IN number default 0,
          phase      OUT varchar2,
          status     OUT varchar2,
          dev_phase  OUT varchar2,
          dev_status OUT varchar2,
          message    OUT varchar2) return boolean
as
begin
  phase := 'my phase';
  status := 'my status';
  dev_phase := 'my dev_phase';
  dev_status := 'my dev_status';
  message := 'my message';
  return(true);
end;
/

show errors

"""

if sys.platform.startswith("darwin"):
    cx_Oracle.init_oracle_client(lib_dir=os.environ.get("HOME")+"/Downloads/instantclient_19_8")

username = os.environ.get("PYTHON_USERNAME")
password = os.environ.get("PYTHON_PASSWORD")
connect_string = os.environ.get("PYTHON_CONNECTSTRING")

connection = cx_Oracle.connect(username, password, connect_string)

cursor = connection.cursor()

lc_phase = cursor.var(str)
lc_status = cursor.var(str)
lc_dev_phase = cursor.var(str)
lc_dev_status = cursor.var(str)
lc_message = cursor.var(str)

bool_result = cursor.callfunc('my_wait_for_request', bool, [123456789,5,15,lc_phase,lc_status,lc_dev_phase,lc_dev_status,lc_message])

print('my_wait_for_request result: ', bool_result)
print(lc_phase.getvalue(),lc_status.getvalue(),lc_dev_phase.getvalue(),lc_dev_status.getvalue(),lc_message.getvalue())

L'output era:

my_wait_for_request result:  True
my phase my status my dev_phase my dev_status my message