PL/SQL process: issue with wording

前端 未结 3 913
孤独总比滥情好
孤独总比滥情好 2021-01-27 10:44

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

相关标签:
3条回答
  • 2021-01-27 10:51

    If you whant do all this in a page process, you don't need to create procedure. Put this code in the source of your page process:

    BEGIN
      FOR indx IN (
        select *
         from EMPLOYEE
      ) LOOP
          APEX_UTIL.CREATE_USER(
            p_user_name    => indx.EMP_USERNAME,
            p_web_password => indx.EMP_PASSWORD,
            p_user_group => indx.EMP_GROUP,
          );
      END LOOP;
    END;
    
    0 讨论(0)
  • 2021-01-27 10:58

    use CREATE PROCEDURE to create a new stored procedure or EXEC <proc name> to execute it

    0 讨论(0)
  • 2021-01-27 11:03

    There are multiple issues with your procedure.

    1. You are missing the CREATE keyword, and that's the root cause for the compile time error. PLS-00103.

    See the documentation for more details on CREATE PROCEDURE statement to create a standalone stored procedure or a call specification.

    EMP_USERNAME IN EMPLOYEE

    1. The data type declaration for the IN parameter is incorrect. You need to do it as:
    EMP_USERNAME IN EMPLOYEE.EMP_USERNAME%TYPE
    1. The FOR LOOP is syntactically incorrect.

    FOR indx IN NVL (EMP_USERNAME.FIRST, 0) .. NVL (EMP_USERNAME.LAST, -1)

    You could do it as:

    SQL> CREATE OR REPLACE
      2  PROCEDURE deploy_emp(
      3      i_emp emp.empno%type)
      4  IS
      5    emp_user VARCHAR2(50);
      6  BEGIN
      7    FOR indx IN
      8    (SELECT ename FROM emp
      9    )
     10    LOOP
     11      BEGIN
     12        BEGIN
     13          SELECT ename INTO emp_user FROM emp WHERE empno = i_emp;
     14        EXCEPTION
     15        WHEN NO_DATA_FOUND THEN
     16          emp_user := NULL;
     17        END;
     18      END;
     19    END LOOP;
     20    dbms_output.put_line(emp_user);
     21  END deploy_emp;
     22  /
    
    Procedure created.
    
    SQL> sho err
    No errors.
    

    Now, let's test it and see:

    SQL> set serveroutput on
    SQL> EXEC deploy_emp(7369);
    SMITH
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
    0 讨论(0)
提交回复
热议问题