2

I'm trying to call FND_CONCURRENT.WAIT_FOR_REQUEST from the PL/SQL API for Concurrent Processing using python and cx_Oracle. In order to call WAIT_FOR_REQUEST the following parameters need to be provided :

(         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;

So my python code looks like:

submitted_request = cursor.var(cx_Oracle.STRING)
phase = cursor.var(cx_Oracle.STRING)
status = cursor.var(cx_Oracle.STRING)
dev_phase = cursor.var(cx_Oracle.STRING)
dev_status = cursor.var(cx_Oracle.STRING)
message = cursor.var(cx_Oracle.STRING)
cursor.callfunc('fnd_concurrent.wait_for_request', submitted_request,
                [141116467,
                 1,
                 1,
                 phase,
                 status,
                 dev_phase,
                 dev_status,
                 message])

But when I try to run the code the following error appears:

cx_Oracle.DatabaseError: ORA-06550: line 1, column 13:
PLS-00382: expression is of wrong type

My insights are that submitted_request is causing the problem but I cannot find in the documentation how to get a boolean from a function (I've already tried int but no luck so far).

Thanks in advance.

3
  • 1
    See this answer to a similar question - I was also going to suggest an anonymous block wrapper to return a valid SQL type. stackoverflow.com/questions/64217140/… Commented Jul 14, 2021 at 18:59
  • It worked, thanks @kfinity Commented Jul 14, 2021 at 20:12
  • Is this a homework question? It was also asked (and answered) at stackoverflow.com/questions/68379599/… Commented Jul 14, 2021 at 23:21

2 Answers 2

2

Following kfinity's suggestion about using an anonymous block wrapper and a pretty similar question, the following code is going to work:

outVal = cursor.var(int)
phase = cursor.var(cx_Oracle.STRING)
status = cursor.var(cx_Oracle.STRING)
dev_phase = cursor.var(cx_Oracle.STRING)
dev_status = cursor.var(cx_Oracle.STRING)
message = cursor.var(cx_Oracle.STRING)
sql="""
  begin
    :outVal := sys.diutil.bool_to_int(
        fnd_concurrent.wait_for_request(
            :id,
            :interval, 
            :max_wait,
            :phase,
            :status,
            :dev_phase,
            :dev_status,
            :message
        )
    );
  end;
  """
cursor.execute( 
    sql,
    outVal=outVal,
    id='141116467',
    interval='1',
    max_wait='1',
    phase=phase,
    status=status,
    dev_phase=dev_phase,
    dev_status=dev_status,
    message=message
)
print(outVal.getvalue())
Sign up to request clarification or add additional context in comments.

2 Comments

In any not-even-so-recent version of cx_Oracle and the Oracle Client, there's no need to map the boolean, see stackoverflow.com/a/68386070/4799035
I'm using cx_Oracle v 8.2.1. And bool conversion is a solution for me. What is version where conversion is not required?
1

You can use boolean directly as follows:

phase = cursor.var(cx_Oracle.STRING)
status = cursor.var(cx_Oracle.STRING)
dev_phase = cursor.var(cx_Oracle.STRING)
dev_status = cursor.var(cx_Oracle.STRING)
message = cursor.var(cx_Oracle.STRING)
submitted_request = cursor.callfunc('fnd_concurrent.wait_for_request', bool,
                [141116467,
                 1,
                 1,
                 phase,
                 status,
                 dev_phase,
                 dev_status,
                 message])

Note that cursor.callfunc() will internally create a variable of the type specified as the return type (bool in this case) and then return the value of that variable as the return value of cursor.callfunc().

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.