Oops, posted the the wrong stored proc code. This is the invocation I was actually using:
create or replace function setClosedProcessToManagerReview(proc_inst_id character varying (64), proc_def_id character varying(64))
returns BOOLEAN LANGUAGE plpgsql AS
$$
BEGIN
INSERT INTO act_ru_execution select id_, 1, proc_inst_id_, business_key_, null, proc_def_id_, null, 'a5managerreview', true, false, true, false, 1, 2, '', null, null
FROM act_hi_procinst
WHERE proc_inst_id_ = proc_inst_id;
INSERT INTO act_ru_task
SELECT (SELECT cast(max(cast(id_ as int)) + 3 as character varying (64)) FROM act_ru_task) as id_,
2,
proc_inst_id,
proc_inst_id,
proc_def_id, 'Manager Review', null , null, 'a5managerreview', null, null, null, 50, now(), null, null, 1, '', '/app/viewdocument/review/';
INSERT INTO act_hi_actinst
SELECT (select cast(max(cast(id_ as int)) + 3 as character varying (64)) from act_hi_actinst), proc_def_id, proc_inst_id, proc_inst_id, 'a5managerreview',
(SELECT id_ FROM act_ru_task WHERE proc_inst_id_ = proc_inst_id), null, 'Manager Review', 'userTask', null, now(), null, null, '';
INSERT INTO act_hi_taskinst
select id_, proc_def_id_, task_def_key_, proc_inst_id_, execution_id_, name_,
null, null, null, assignee_, create_time_, null, null, null, null, 50, null, form_key_, category_, tenant_id_ FROM act_ru_task WHERE proc_inst_id_ = proc_inst_id;
UPDATE act_hi_procinst
SET end_time_ = null, duration_=null, end_act_id_ = null
WHERE proc_inst_id_ = proc_inst_id;
INSERT INTO act_ru_variable
SELECT id_, rev_, var_type_, name_, execution_id_, proc_inst_id_, task_id_, bytearray_id_, double_, long_, text_, text2_
FROM act_hi_varinst
WHERE proc_inst_id_ = proc_inst_id;
INSERT INTO act_ru_identitylink
SELECT (SELECT cast(max(cast(id_ as int)) + 3 as character varying (64)) FROM act_ru_identitylink),
1, 'ProjectLeader', 'candidate', null, (SELECT id_ FROM act_ru_task WHERE proc_inst_id_ = proc_inst_id), null, null;
return true;
END;
$$;
select setClosedProcessToManagerReview(proc_inst_id_, 'documentupload:23:1722512') from act_hi_procinst
WHERE end_time_ is not null AND end_act_id_ = 'a6goodocrfinish' AND delete_reason_ is null;