-------------------------------------- 
-- API ORACLE PARA ADICIONAR USUÁRIO
-- -------------------------------------- 
DECLARE 
   lc_user_name                      VARCHAR2(100)  := 'TESTE_USER'; 
   lc_user_password                  VARCHAR2(100)  := 'Oracle123'; 
   ld_user_start_date                DATE           := TO_DATE('23-JUN-2012'); 
   ld_user_end_date                  VARCHAR2(100)  := NULL; 
   ld_password_date                  VARCHAR2(100)  := SYSDATE; 
   ld_password_lifespan_days         NUMBER         := 90; 
   ln_person_id                      NUMBER         := NULL; -- AQUI SERIA O ID DE UMA PESSOA CADASTRADA NO HR exemplo, funcionário.
   lc_email_address                  VARCHAR2(100)  := 'teste_user@abc.com';
BEGIN 
  fnd_user_pkg.createuser (x_user_name                => lc_user_name, 
                           x_owner                    => NULL, 
                           x_unencrypted_password     => lc_user_password, 
                           x_start_date               => ld_user_start_date, 
                           x_end_date                 => ld_user_end_date, 
                           x_password_date            => ld_password_date, 
                           x_password_lifespan_days   => ld_password_lifespan_days, 
                           x_employee_id              => ln_person_id, 
                           x_email_address            => lc_email_address); 
 COMMIT;
EXCEPTION 
  WHEN OTHERS THEN 
    ROLLBACK; 
      DBMS_OUTPUT.PUT_LINE(SQLERRM); 
END; 
/

-- ---------------------------------------------------------- 
-- API PARA ADICIONAR RESPONSABILIDADES PARA UM USUÁRIO
-- ----------------------------------------------------------- 
DECLARE 
    lc_user_name              VARCHAR2(100)    := 'TESTE_USER'; 
    lc_resp_appl_short_name   VARCHAR2(100)    := 'FND'; 
    lc_responsibility_key     VARCHAR2(100)    := 'APPLICATION_DEVELOPER'; 
    lc_security_group_key     VARCHAR2(100)    := 'STANDARD'; 
    ld_resp_start_date        DATE             := SYSDATE; 
    ld_resp_end_date          DATE             := NULL; 

BEGIN 
     fnd_user_pkg.addresp(username           => lc_user_name, 
                          resp_app            => lc_resp_appl_short_name, 
                          resp_key            => lc_responsibility_key, 
                          security_group      => lc_security_group_key, 
                          description         => NULL, 
                          start_date          => ld_resp_start_date, 
                          end_date            => ld_resp_end_date);
 COMMIT; 
EXCEPTION 
  WHEN OTHERS THEN 
    ROLLBACK; 
      DBMS_OUTPUT.PUT_LINE(SQLERRM); 
END; 

Deixe um comentário