Tuesday 15 May 2012

Update Oracle Apps User Details

Once the users have been created in the oracle system, there might be scenarios when there is a requirement to update some properties of the user.
 Oracle Provides an API for the functionality: fnd_user_pkg.updateuser

Given below is a sample script to perform the intended functionality


declare

  v_session_id INTEGER := userenv('sessionid');
  v_user_name  VARCHAR2(30) := upper('test2');
begin

fnd_user_pkg.UpdateUser (
  x_user_name                  => v_user_name,
  x_owner                      => 'CUST',
  x_unencrypted_password       => '456789',  --new password
  x_session_number             => v_session_id,
  x_start_date                 => null,
  x_end_date                   => null, -- populated when disabling the user
  x_last_logon_date            => null,
  x_description                => null,
  x_password_date              => null,
  x_password_accesses_left     => null,
  x_password_lifespan_accesses => null,
  x_password_lifespan_days     => null,
  x_employee_id                             => null,
  x_email_address              => null,
  x_fax                          => null,
  x_customer_id                              => null,
  x_supplier_id                 => null,
  x_old_password               => 'asdfg'  --old password
);

  EXCEPTION
  WHEN OTHERS
  THEN
     dbms_output.put_line('Exception Occurred in Processing ');
     dbms_output.put_line('Oracle Error '||SQLERRM);
END;

In case the user exists in the system the API will successfully update the uses properties. In case no user with the provided username exists in the system Oracle will throw an error.

1 comment: