Friday, September 5, 2014

HRMS API: Create Contact Person hr_contact_rel_api.create_contact

DECLARE
   p_start_date                  DATE;
   p_person_id                   NUMBER;
  


 p_contact_type                VARCHAR2 (500);
   p_last_name                   VARCHAR2 (500);
   v_err                         VARCHAR2 (1000);
--------------------------------------------
   p_contact_relationship_id     NUMBER;
   p_ctr_object_version_number   NUMBER;
   p_per_person_id               NUMBER;
   p_per_object_version_number   NUMBER;
   p_per_effective_start_date    DATE;
   p_per_effective_end_date      DATE;
   p_full_name                   VARCHAR2 (500);
   p_per_comment_id              NUMBER;
   p_name_combination_warning    BOOLEAN;
   p_orig_hire_warning           BOOLEAN;
BEGIN
   SELECT per.person_id, per.effective_start_date
     INTO p_person_id, p_start_date
     FROM per_all_people_f per
    WHERE per.employee_number = '91314'
      AND per.effective_end_date = TO_DATE ('12/31/4712', 'MM/DD/RRRR');
   BEGIN
      hr_contact_rel_api.create_contact
                 (p_start_date                     => p_start_date,
                  p_business_group_id              => 101,
                  p_person_id                      => p_person_id,
                  p_person_type_id                 => 1125,
                  p_contact_type                   => 'C',
                  p_personal_flag                  => 'Y',
                  p_last_name                      => 'Ganna',
                  p_sex                            => 'F',
                  p_attribute_category             => 'OTHER',
                  p_attribute1                     => 'Egypt',
                  p_attribute2                     => 'Cairo',
                  p_contact_relationship_id        => p_contact_relationship_id,
                  p_ctr_object_version_number      => p_ctr_object_version_number,
                  p_per_person_id                  => p_per_person_id,
                  p_per_object_version_number      => p_per_object_version_number,
                  p_per_effective_start_date       => p_per_effective_start_date,
                  p_per_effective_end_date         => p_per_effective_end_date,
                  p_full_name                      => p_full_name,
                  p_per_comment_id                 => p_per_comment_id,
                  p_name_combination_warning       => p_name_combination_warning,
                  p_orig_hire_warning              => p_orig_hire_warning
                 );
      DBMS_OUTPUT.put_line ('Done ' || p_per_person_id);
   EXCEPTION
      WHEN OTHERS
      THEN
         v_err := NULL;
         v_err := SQLERRM;
         p_start_date := NULL;
         p_person_id := NULL;
         p_contact_type := NULL;
         p_contact_relationship_id := NULL;
         p_ctr_object_version_number := NULL;
         p_per_person_id := NULL;
         p_per_object_version_number := NULL;
         p_per_effective_start_date := NULL;
         p_per_effective_end_date := NULL;
         p_full_name := NULL;
         p_per_comment_id := NULL;
         p_name_combination_warning := NULL;
         p_orig_hire_warning := NULL;
         DBMS_OUTPUT.put_line (v_err);
   END;

   COMMIT;
END;