I have an application in which a user creates a form, for which several responsible persons are selected in this form and can edit this form.
As soon as the form is submitted, the corresponding page of the process is changed. The page of the form and the respective responsible persons are saved in a separate table. The function has to check whether the logged-in user with the user ID is entered in the table as one of the responsibles. The table for example Responsible1 contains a foreign key to the table USERS, in which the ID is located. As soon as it finds the responsible in the table, the function then should redirect the user to the corresponding page.
create or replace function forward_user(p_username in varchar2)
return varchar2
is
l_user varchar2(255);
l_branch_page number;
begin
l_user :=p_username;
/*
Get the target page depending on entry in table
*/
select
page
into l_branch_page
from
FORM_PAGES
where EXISTS (SELECT f.RESP1 from FORM f
left outer join RESPONSIBLE1 s on s.RESP1=f.RESP1
LEFT OUTER JOIN USERS u on u.ID=s.ID where lower(u.USERNAME) =lower(l_user) )
OR (fp.RESP2 in
(SELECT f.RESP2 from FORM f
left outer join RESPONSIBLE2 p on p.RESP2=f.RESP2
left outer join USERS u on u.ID=p.ID where lower(u.USERNAME) =lower(l_user) ))
OR (fp.RESP3 in (select f.RESP from FORM f
left outer join RESPONSIBLE3 e on e.RESP3=f.RESP3
left outer join USERS u on u.ID=e.ID where lower(u.USERNAME) =lower(l_user) ));
return APEX_PAGE.GET_URL(p_page =>l_branch_page);
exception
when no_data_found then
/*Use current page as default page*/
return APEX_PAGE.GET_URL(p_page =>1);
end ;
I then call this function in a pl/sql process when the button NEXT is clicked.
DECLARE
x varchar2(4000);
BEGIN
x:=forward_user(:session_user_name);
END;
I have already checked the sql statements and they work fine, I get the corresponding page. As well the function compiles successfully. But when I click the button nothing happens, the user is not forwarded to the stored page in the table.
As well I tried to call this function in a branching process with the behaviour Function Returning a URL(Redirect) but as well nothing happens.
Can someone help me here?