flowsforapex / apex-flowsforapex

Flows for APEX - Model and run process flows all within Oracle APEX!
https://flowsforapex.org
Other
80 stars 40 forks source link

[bug]: Unable to reschedule an interrupting timer #710

Open LouisMoreaux opened 2 months ago

LouisMoreaux commented 2 months ago

Flows for APEX version

23.1 (latest)

Oracle Database version

19c

Oracle APEX version

23.1

Have you used the BPMN-Linter in Flow Designer to Validate your Diagram?

Yes

What happened?

Trying to reschedule interrupting timers using the flow_api_pkg.flow_reschedule_timer procedure but got the error

ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "FLOWS4APEX.FLOW_TIMERS_PKG", line 854
ORA-06512: at "FLOWS4APEX.FLOW_API_PKG", line 305
ORA-06512: at line 31
01422. 00000 -  "exact fetch returns more than requested number of rows"
*Cause:    The number specified in exact fetch is less than the rows returned.
*Action:   Rewrite the query or change number of rows requested

Steps to reproduce

Create a simple diagram containing at least two interrupting timers on the same subflow image

Run the following code to reschedule the timer

set serveroutput on
declare
   type t_timer is record (
      prcs_id flow_subflows.sbfl_prcs_id%type, 
      sbfl_id flow_subflows.sbfl_id%type, 
      step_key flow_subflows.sbfl_step_key%type
   );
   type t_timers is table of t_timer;
   l_timers t_timers;
begin

   select sbfl.sbfl_prcs_id, sbfl.sbfl_id, sbfl.sbfl_step_key
   bulk collect into l_timers
   from flow_timers timr
   join flow_subflows sbfl
     on sbfl.sbfl_id = timr.timr_sbfl_id
   where timr.timr_prcs_id = 757;

   sys.dbms_output.put_line(apex_string.format('Rescheduling %0 timers', l_timers.count()));

   for i in l_timers.first..l_timers.last
   loop
      sys.dbms_output.put_line(
         apex_string.format(
            '%3 - prcs_id: %0, sblf_id: %1, step_key: %2', 
            l_timers(i).prcs_id, 
            l_timers(i).sbfl_id , 
            l_timers(i).step_key,
            i
         )
      );
      flow_api_pkg.flow_reschedule_timer(
           p_process_id    => l_timers(i).prcs_id
         , p_subflow_id    => l_timers(i).sbfl_id 
         , p_step_key      => l_timers(i).step_key
         , p_new_timestamp => systimestamp + interval '20' day
         , p_comment       => 'Rescheduling timer again'
      );
   end loop;
   commit;
   sys.dbms_output.put_line('Done');
end;

Expected behaviour

No error, timer is reschedule correctly