PL/SQL Script to Create Adhoc Role

DECLARE
  ln_role_count NUMBER;
  lc_role_name apps.wf_roles.NAME%TYPE                := 'XX_TEST_ROLE';
  lc_role_display_name apps.wf_roles.description%TYPE := 'XX Test Role';
BEGIN
  ------------------------------
  --Checking if Adhoc Role Exits
  ------------------------------
  SELECT COUNT (1)
  INTO ln_role_count
  FROM apps.wf_roles
  WHERE NAME       = lc_role_name;
 
  IF ln_role_count = 0 THEN
      ---------------------
	  --Creating Adhoc Role
      ---------------------
    apps.wf_directory.createadhocrole 
          (role_name               => lc_role_name,
           role_display_name       => lc_role_display_name, 
           notification_preference => 'MAILHTM2' );
 
    dbms_output.put_line("Role Created!");
  END IF;
END; 
/

NOTE: You should not use COMMIT in this script if you are using this in a Procedure of a Workflow Activity.

Also See: