2020/08/10

[User] Create user by api

 DECLARE

  vEmpNum    hr_employees.employee_num%TYPE := 'xxx';

  vStartDate fnd_user.start_date%TYPE := SYSDATE;

  vEndDate   fnd_user.end_date%TYPE := NULL;

  vPassword  fnd_user.web_password%TYPE;

  vSessionId fnd_user.session_number%TYPE := userenv('sessionid');

  vEmp       hr_employees%ROWTYPE;

BEGIN


  SELECT *

  INTO   vEmp

  FROM   hr_employees he

  WHERE  he.employee_num = vEmpNum;

  vPassword := dbms_random.string('p', 10);


  fnd_user_pkg.CreateUser(x_user_name => vEmp.employee_num, x_owner => NULL,

                          x_unencrypted_password => vPassword,

                          x_session_number => vSessionId,

                          x_start_date => vStartDate, x_end_date => vEndDate,

                          x_employee_id => vEmp.employee_id);

  dbms_output.put_line('Password : ' || vPassword);

EXCEPTION

  WHEN OTHERS THEN

    dbms_output.put_line(dbms_utility.format_error_stack);

END;


沒有留言: