I am trying to create a page process in Oracle APEX 4.1. Specifically, When a button on this page is process submitting the page, I want this PL/SQL query to work. I don't have much of an understanding of PL/SQL and am looking to find out how to figure this issue out.
What I want the query to do:
I would like this page process to loop through each row in the EMPLOYEE table that I have in a database for APEX. For each row, I want to move the username, group and password into their own variables, and then to create an APEX user using the APEX_UTIL_CREATE_USER process. I want this to be done with every employee in the table.
I don't know specifically what is wrong with this PL/SQL, as I have never had to use it before. I would greatly appreciate any help anyone can give me with this. I will show the query and the error message below.
PL/SQL query:
PROCEDURE deploy_employee (EMP_USERNAME IN EMPLOYEE) IS BEGIN FOR indx IN NVL (EMP_USERNAME.FIRST, 0) .. NVL (EMP_USERNAME.LAST, -1) LOOP emp_user EMPLOYEE.EMP_USERNAME%TYPE; emp_pass EMPLOYEE.EMP_PASSWORD%TYPE; emp_group EMPLOYEE.EMP_GROUP%TYPE; BEGIN BEGIN select EMP_USERNAME into emp_user from EMPLOYEE; select EMP_PASSWORD into emp_pass from EMPLOYEE; select EMP_GROUP into emp_group FROM EMPLOYEE; EXCEPTION WHEN NO_DATA_FOUND THEN emp_user := NULL; emp_pass := NULL; emp_group := NUL; END; APEX_UTIL.CREATE_USER( p_user_name => emp_user, p_web_password => emp_pass, p_user_group => emp_gorup, ); END; END LOOP; END deploy_employee;
Error message:
1 error has occurred ORA-06550: line 2, column 1: PLS-00103: Encountered the symbol "PROCEDURE" when expecting one of the following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge The symbol "declare" was substituted for "PROCEDURE" to continue. ORA-065
The page number is 2.
Once again I would be greatly appreciative of any help I could gain.